Giter Site home page Giter Site logo

hyperledger / fabric-sdk-py Goto Github PK

View Code? Open in Web Editor NEW
406.0 44.0 203.0 7.44 MB

Hyperledger Fabric Python SDK

Home Page: https://fabric-sdk-py.readthedocs.io/en/latest/

License: Apache License 2.0

Python 97.04% Makefile 0.33% Shell 0.44% Dockerfile 0.04% Jupyter Notebook 2.15%
hyperledger fabric blockchain distributed-ledger python

fabric-sdk-py's Introduction

Fabric-SDK-Py

Fabric-SDK-Py is the Python 3.x implementation of Hyperledger Fabric SDK!

Currently, it mainly supports Fabric 1.4.x version.

Pre-requisite

The SDK requires the Python3 and Libssl pkgs.

Run the following cmd to install the pre-requisites if you do not have:

OS command
Ubuntu/Debian sudo apt-get install python-dev python3-dev libssl-dev
Redhat/CentOS sudo yum install python-devel python3-devel openssl-devel
MacOS brew install python python3 openssl

More details to build the crypto lib, can be found at Install Python Cryotography Lib.

Tutorial

Read the Tutorial (Source) to get familiar with the APIs. A jupyter notebook explaining the sample code can be found here.

Quick Testing

Use Virtual Env

virtualenv helps provide a clean environment, suggest to use it to test.

$ pip3 install virtualenv # install the virtualenv tool if not installed
$ make venv  # create a virtual env
$ source venv/bin/activate
$ # Do the testing here
$ deactivate  # deactive the virtual env
$ make clean # clean the temporary files

Run Integration Testing

The following command will run the testing.

$ make check # Check environment and run tests
$ make test # Only run test cases
$ tox -e py3 -- test/integration/ca_test.py  # Run specified test case

Generating Docker images

The following command will build the Docker image hyperledger/fabric-sdk-py.

$ make image

Regenerating protos

Make sure you have grpcio-tools installed (pip install grpcio-tools)

$ make proto

Change Logs

See Change Log for the commit logs. Run make changelog to update the changelog before new release.

Bug, Question and Code Contributions

Welcome for any kind of contributions, e.g., bugs, questions and documentation!

Recommend to read How to Contribution before taking action.

Other Important Links

License

The Hyperledger Fabric-SDK-Py software uses the Apache License Version 2.0 software license.

Creative Commons License
This document is licensed under a Creative Commons Attribution 4.0 International License.

fabric-sdk-py's People

Contributors

aureliengasser avatar denyeart avatar dependabot[bot] avatar dexhunter avatar dpdornseifer avatar grapebaba avatar guillaumecisco avatar h0rs3fa11 avatar hengfun avatar hritikgupta avatar jadarlin avatar kelvin-m avatar kivenchen avatar lafenicecc avatar lucas-wye avatar nobody4t avatar oldsharp avatar pcsx22 avatar qiang0723 avatar rakaar avatar rameshthoomu avatar rohanshrothrium avatar rranjan3 avatar ryjones avatar sudheesh001 avatar tcz001 avatar tijohnson avatar vieirin avatar viragumathe5 avatar yeasy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fabric-sdk-py's Issues

Problem creating channel in python tutorial

Hello. I am having trouble running the python sdk example to create a channel with the default values. I have already added the binaries to my path, etc.

This is the code I am running within the fabric-sdk-py folder:
import asyncio
from hfc.fabric import Client
loop = asyncio.get_event_loop()

cli = Client(net_profile="test/fixtures/network.json")
print(cli.organizations) # orgs in the network
print(cli.peers) # peers in the network
print(cli.orderers) # orderers in the network
print(cli.CAs) # ca nodes in the network

org1_admin = cli.get_user(org_name='org1.example.com', name='Admin')

Create a New Channel, the response should be true if succeed

response = loop.run_until_complete(cli.channel_create(
orderer='orderer.example.com',
channel_name='businesschannel',
requestor=org1_admin,
config_yaml='test/fixtures/e2e_cli/',
channel_profile='TwoOrgsChannel'
))
print(response == True)

And the error I am getting is:
Init client with profile=test/fixtures/network.json
create org with name=orderer.example.com
create org with name=org1.example.com
create org with name=org2.example.com
create ca with name=ca-org1
create ca with name=ca-org2
Import orderers = dict_keys(['orderer.example.com'])
Import peers = dict_keys(['peer0.org1.example.com', 'peer1.org1.example.com', 'peer0.org2.example.com', 'peer1.org2.example.com'])
{'orderer.example.com': <hfc.fabric.organization.Organization object at 0x7f7d1a9d9a60>, 'org1.example.com': <hfc.fabric.organization.Organization object at 0x7f7d1cebadf0>, 'org2.example.com': <hfc.fabric.organization.Organization object at 0x7f7d1ced5e50>}
{'peer0.org1.example.com': <hfc.fabric.peer.Peer object at 0x7f7d1ced5760>, 'peer1.org1.example.com': <hfc.fabric.peer.Peer object at 0x7f7d1ced5280>, 'peer0.org2.example.com': <hfc.fabric.peer.Peer object at 0x7f7d1ced5eb0>, 'peer1.org2.example.com': <hfc.fabric.peer.Peer object at 0x7f7d1a68c790>}
{'orderer.example.com': <hfc.fabric.orderer.Orderer object at 0x7f7d1ced56a0>}
{'ca-org1': <hfc.fabric.certificateAuthority.certificateAuthority object at 0x7f7d1ced5d60>, 'ca-org2': <hfc.fabric.certificateAuthority.certificateAuthority object at 0x7f7d1ced5a60>}
FABRIC_CFG_PATH set to /home/hoovert/fabric-sdk-py/test/fixtures/e2e_cli/
--- Logging error ---
Traceback (most recent call last):
File "/usr/local/lib/python3.9/logging/init.py", line 1079, in emit
msg = self.format(record)
File "/usr/local/lib/python3.9/logging/init.py", line 923, in format
return fmt.format(record)
File "/usr/local/lib/python3.9/logging/init.py", line 659, in format
record.message = record.getMessage()
File "/usr/local/lib/python3.9/logging/init.py", line 363, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
File "/home/hoovert/fabric-sdk-py/test1.py", line 16, in
response = loop.run_until_complete(cli.channel_create(
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 629, in run_until_complete
self.run_forever()
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 596, in run_forever
self._run_once()
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1890, in _run_once
handle._run()
File "/usr/local/lib/python3.9/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/home/hoovert/fabric-sdk-py/hfc/fabric/client.py", line 505, in channel_create
tx = self.generate_channel_tx(channel_name, config_yaml,
File "/home/hoovert/fabric-sdk-py/hfc/fabric/client.py", line 1117, in generate_channel_tx
_logger.error('Failed to generate transaction file', err)
Message: 'Failed to generate transaction file'
Arguments: (b'\x1b[34m2021-02-23 16:39:18.006 -05 [common.tools.configtxgen] main -> INFO 001\x1b[0m Loading configuration\n\x1b[34m2021-02-23 16:39:18.010 -05 [common.tools.configtxgen.localconfig] Load -> INFO 002\x1b[0m Loaded configuration: /home/hoovert/fabric-sdk-py/test/fixtures/e2e_cli/configtx.yaml\n\x1b[34m2021-02-23 16:39:18.010 -05 [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 003\x1b[0m Generating new channel configtx\n\x1b[35m2021-02-23 16:39:18.010 -05 [common.tools.configtxgen] main -> FATA 004\x1b[0m Error on outputChannelCreateTx: could not generate default config template: error parsing configuration: error adding policies to channel group: no policies defined\n',)
Configtx is empty
False

Any help greatly appreciated.

Dear developer,Is this an issue? thanks

Dear developer,when i run the lifecycle_test.py,everything is OK,the test has complete,but here are some logs like a warning.
"No config file found",
"localHost :NONE"
I don't know where I'm going wrong,........thanks!

image

400 when invoking chaincode using tutorial

Hi, I'm just trying to get the tutorial code running. It errors with "response" of "400" when invoking the example chaincode.

I'm running on an Ubuntua 20.04 server. All of the containers seem to start up correctly. The "TLDR" quick test returns "...1 passed, 12 warnings...py3: commands succeeded...congratulations...".

My code, tutorial.py, is copied from https://fabric-sdk-py.readthedocs.io/en/latest/tutorial.html. (I was going to use the code from Tutorial.ipynb, but it seems to be missing code to define "loop".) I haven't modified the tutorial code other than to place it in one script, move the imports to the top, add comments, and print outputs.

Please help with any hints or advice. I've spent days trying to get this working. Thank you!

Rob Campbell
Research Computing
Purdue University

2021 Mentorship Program

Dear Potential Mentees,

Hi, thank you for your interest in the fabric-sdk-py project. Our current priority is to add features supporting Fabric 2.x, especially for the chaincode management. Feel free to check other open issues. To make you more competitive in the application process, you are advised to make contributions to the codebase. You can fix typos/URLs, report a bug, add a feature, and other contributions to the project. You are also encouraged to join our rocketchat via channel #fabric-sdk-py. If there are any other issues you want to ask, feel free to comment on this thread.

Some resources:

Kind Regards,
Dex Dixing Xu

release of LTS version 1.0.0 (supporting Fabric v1.4.x)

Firstly, congratulations to @RohanShrothrium for being admitted to the mentorship program. Secondly, I am starting this issue to track which features of Fabric v1.4.x are still not implemented. Thirdly, after all reported missing features added, we will release fabric-sdk-py v1.0.0 as long-term support (LTS) version and start working on support for fabric 2.x

Can I keep listening to channel events until the stop block generated?

If the current block height is 10000, here is my code

async def get_filter_block_events(org, peer, channel, stop_height):
    org_user = client.get_user(org, "User1")
    channel = client.get_channel(channel)
    peer_info = client.get_peer(peer)
    channel_event_hub = channel.newChannelEventHub(peer_info, org_user)
    channel_event_hub.registerBlockEvent(unregister=False, start=height, stop=stop_height, onEvent=onFilteredEvent)
    stream = channel_event_hub.connect(filtered=True)

    await stream

def test_event():
    org = 'org1'
    peer = 'peer1.org1'
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main(org, peer, channel, 10010))

the stop block is 10010, but the program is not going to wait, it will stop when there is no block.
How can I make the program to keep waiting until reach block 10010?

Unable invoke and query the chaincode through the Gateway

I came through an issue where I want to evaluate a transaction in a chaincode, however, the code fabric-sdk-py/hfc/fabric_network/contract.py seems broken at the evaluate_transaction function:

    async def evaluate_transaction(self, **name**, args, requestor):
        channel_name = self.network.**channel3**
        cli = self.gatetway.client
        peers = cli._peers

        response = await cli.chaincode_query(requestor=requestor,
                                             channel_name=channel_name,
                                             peers=peers,
                                             args=args,
                                             cc_name=self.cc_name)
        return response

The first issue is with the channel3 variable which doesn't exist. The second issue is with nameargument of the evaluate_transaction function which seems no not be used.
Could you please check?

Unable to import Client in fabric-sdk-py version 0.9.0

I am using the following system configuration:

  1. Python version 3.7.7
  2. fabric-sdk-py version 0.9.0 (built from source - master branch)
  3. Debian OS - Buster 10
  4. grpcio version 1.20.1

While importing Client using this command from hfc.fabric.client import Client, I get the following error:
ImportError: cannot import name '_MultiThreadedRendezvous' from 'grpc._channel'

But when I install fabric-sdk-py using pip install fabric-sdk-py which results in fabric-sdk-py version of 0.8.1, I did not get any error when importing Client.

Looks like there is bug/compatibility issue with grpc and the fabric-sdk-py built from the master branch.

Mentorship Program 2020

Dear Potential Mentees,

Hi, thank you for your interest in the fabric-sdk-py project. Our current priority is to add features supporting Fabric 1.4.x. You can take a reference from nodejs/golang sdk (release-1.4). To make you more competitive in the application process, you are advised to make contributions to the codebase. You can fix typos/urls, report a bug, add a feature and other contributions towards the project. You are also encouraged to join our rocketchat via channel #fabric-sdk-py. If there are any other issues you want to ask, feel free to comment on this thread.

Some resources:

Kind Regards,
Dixing (Dex) Xu

How to register for chain code event using custom filter like latest block

How to register for chain code event starting from the latest block. Something like below
channel_event_hub.registerChaincodeEvent(CC_NAME, 'invoked', start='latest',
onEvent=_event_handler);

Where 'latest' corresponds to latest block number.

Or else how do i get the latest block number using fabric python sdk so that i can pass the latest block number to registerChaincodeEvent()

make check fails on wsl (windows subsystem for linux)

I was trying to test the codebase and found that I was unable to execute the make check command due to the $PATH settings in wsl. The solution is found there

PATH=$(/usr/bin/printenv PATH | /usr/bin/perl -ne 'print join(":", grep { !/\/mnt\/[a-z]/ } split(/:/));')

Modify Makefile

Currently, the makefile is not flexible if your system's python and pip is not define as python3 and pip3

Discovery service Peer TLS CA Cert problem

Hi,
When I use fabric client discovery service, a gRPC channel is created for every peer in network using wrong TLS CA Cert because it is base64 encoded.

If I query Peer information, I get the following output:

[Peer:_name=peer0.org2.example.com,_lock=<unlocked _thread.RLock object owner=0 count=0 at 0x7fbf370bc780>,_channels=[],_endpoint=peer0.org2.example.com:9051,_grpc_options={'grpc.ssl_target_name_override': 'peer0.org2.example.com'},_ssl_target_name=peer0.org2.example.com,_tls_ca_certs_path=b'LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNWekNDQWYyZ0F3SUJBZ0lRY0RHeWRDVnVrSUpqekNsWUlmcHltekFLQmdncWhrak9QUVFEQWpCMk1Rc3cKQ1FZRFZRUUdFd0pWVXpFVE1CRUdBMVVFQ0JNS1EyRnNhV1p2Y201cFlURVdNQlFHQTFVRUJ4TU5VMkZ1SUVaeQpZVzVqYVhOamJ6RVpNQmNHQTFVRUNoTVFiM0puTWk1bGVHRnRjR3hsTG1OdmJURWZNQjBHQTFVRUF4TVdkR3h6ClkyRXViM0puTWk1bGVHRnRjR3hsTG1OdmJUQWVGdzB5TURBMk1Ua3hNelU1TURCYUZ3MHpNREEyTVRjeE16VTUKTURCYU1IWXhDekFKQmdOVkJBWVRBbFZUTVJNd0VRWURWUVFJRXdwRFlXeHBabTl5Ym1saE1SWXdGQVlEVlFRSApFdzFUWVc0Z1JuSmhibU5wYzJOdk1Sa3dGd1lEVlFRS0V4QnZjbWN5TG1WNFlXMXdiR1V1WTI5dE1SOHdIUVlEClZRUURFeFowYkhOallTNXZjbWN5TG1WNFlXMXdiR1V1WTI5dE1Ga3dFd1lIS29aSXpqMENBUVlJS29aSXpqMEQKQVFjRFFnQUVrRGZXYmJBV0FadURvSWRGSUZhZFdmVWEyTldvVWhhWVNlTjJRZDBWUjRQMVhqRDJKWXEvR0QxZQpqb3pWajBNSzZNaVZraGI5aUNJdmw5Ynp5L2FvSmFOdE1Hc3dEZ1lEVlIwUEFRSC9CQVFEQWdHbU1CMEdBMVVkCkpRUVdNQlFHQ0NzR0FRVUZCd01DQmdnckJnRUZCUWNEQVRBUEJnTlZIUk1CQWY4RUJUQURBUUgvTUNrR0ExVWQKRGdRaUJDQkNhYjBWQXR6VjJVd2pXYXRyK0F0VkZCeXgwTXV5Y29Oem5mYmNMNDErOFRBS0JnZ3Foa2pPUFFRRApBZ05JQURCRkFpQUNCVlMyTWlvWlE5RzdTODRLZWlJSGh2cVM1N3Y3akxtQmVwYlVKeTNBMEFJaEFQakwrbUR4CmZNc3NiRk0zWk5VMThhZlkxTWdObkFEeGRkZ20vcTFoZnZwbAotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==',_client_key_path=None,_client_cert_path=None,_channel=<aiogrpc.channel.Channel object at 0x7fbf37077828>,_endorser_client=<hfc.protos.peer.peer_pb2_grpc.EndorserStub object at 0x7fbf37077208>,_discovery_client=<hfc.protos.discovery.protocol_pb2_grpc.DiscoveryStub object at 0x7fbf370774a8>,_event_client=<hfc.protos.peer.events_pb2_grpc.DeliverStub object at 0x7fbf37077550>]

The important information is in _tls_ca_certs_path, where is the TLS CA Cert in PEM format but encoded, so when util/channel:create_grpc_channel is called, it fails generating the secure channel.

    if cert_file:
        if isinstance(cert_file, bytes):
            root_cert = cert_file
        ...
E0619 17:19:57.225199736    5156 ssl_transport_security.cc:738] Could not load any root certificate.
E0619 17:19:57.225230344    5156 ssl_transport_security.cc:1837] Cannot load server root certificates.
E0619 17:19:57.225251080    5156 ssl_security_connector.cc:113] Handshaker factory creation failed with TSI_INVALID_ARGUMENT.
E0619 17:19:57.225260517    5156 secure_channel_create.cc:132] Failed to create secure subchannel for secure name 'peer0.org2.example.com:9051'
E0619 17:19:57.225270501    5156 secure_channel_create.cc:50] Failed to create channel args during subchannel creation.

Decoding the bytes in util/channel.py:create_grpc_channel fixed the problem. However, I'm not sure what are the consequences in other functions.

    if cert_file:
        if isinstance(cert_file, bytes):
            root_cert = base64.b64decode(cert_file)
        ...

Edit: I have checked and it also happens when orderer TLS CA Cert is loaded with discovery.

"configtxgen not in PATH. Configtx is empty" if anyone can help me? thanks

when i test the SDK linke this: tox -e py3 -- test/integration/e2e_test.py
i have a error:

E2E testing started...
New channel with name = testchainid
E2E: Get channel testchainid config start
E2E: Get channel testchainid config done
E2E: Channel creation start: name=businesschannel
configtxgen not in PATH.
Configtx is empty
tear down
F

my configtxgen have been setting in gopath, i need help ,thx

Channel created fail

Hello, I was following the tutorial of the Fabric Python SDK.

First I set up the network with the commands given.

export HLF_VERSION=1.4.0
docker pull hyperledger/fabric-peer:${HLF_VERSION} \
    && docker pull hyperledger/fabric-orderer:${HLF_VERSION} \
    && docker pull hyperledger/fabric-ca:${HLF_VERSION} \
    && docker pull hyperledger/fabric-ccenv:${HLF_VERSION}
docker-compose -f test/fixtures/docker-compose-2orgs-4peers-tls.yaml up

Then I tried to create a channel and join a peer like the following.

async def async_main():
    cli = Client(net_profile=CONNECTION_PROFILE_PATH)

    print(cli.organizations) # orgs in the network
    print(cli.peers) # peers in the network
    print(cli.orderers) # orderers in the network
    print(cli.CAs) # ca nodes in the network

    # get the admin user from local path
    org1_admin = cli.get_user(org_name='org1.example.com', name='Admin')

    # Create a New Channel, the response should be true if succeed
    response = await cli.channel_create(
        orderer='orderer.example.com',
        channel_name='businesschannel',
        requestor=org1_admin,
        config_yaml=CONFIG_YAML_PATH,
        channel_profile='TwoOrgsChannel'
    )
    if response:
        print("Create channel successful")
    else:
        print("Create channel failed")
        print(response)
        exit(-1)

    # Join Peers into Channel, the response should be true if succeed
    response = await cli.channel_join(
        requestor=org1_admin,
        channel_name='businesschannel',
        peers=['peer0.org1.example.com', 'peer1.org1.example.com'],
        orderer='orderer.example.com')
    if response:
        print("Join channel successful")
    else:
        print("Join channel failed")
        exit(-1)

def main():
    loop = asyncio.get_event_loop()
    loop.run_until_complete(async_main())

if __name__ == '__main__':
    main()

But the response reported back is False. Really not sure about the cause and how to debug on the issue. Some help might be needed on how to correctly use the client to interact with the Fabric network.

enroll admin error

Hi, all!

I set all the environment locally and run the fabcar example in fabric_sample.
downloaded this python version sdk, run : adminEnrollment = casvc.enroll("admin","adminpw")

the error shows like: json.decoder.JSONDecodeError expecting value: line 1 column 1 (char 0)

I was blocked by this error for 2 days, if anyone knows why just let me know, thank you in advance!

Init client with profile=test/fixtures/network.json
create org with name=orderer.example.com
create org with name=org1.example.com
create org with name=org2.example.com
create ca with name=ca-org1
create ca with name=ca-org2
Import orderers = dict_keys(['orderer.example.com'])
Import peers = dict_keys(['peer0.org1.example.com', 'peer1.org1.example.com', 'peer0.org2.example.com', 'peer1.org2.example.com'])
Traceback (most recent call last):
File "lr.py", line 61, in
adminEnrollment = casvc.enroll("admin","adminpw") # now local will have the admin enrollment
File "/home/yusen/Desktop/fabric-sdk-py/hfc/fabric_ca/caservice.py", line 484, in enroll
enrollmentCert, caCertChain = self._ca_client.enroll(
File "/home/yusen/Desktop/fabric-sdk-py/hfc/fabric_ca/caservice.py", line 328, in enroll
res, st = self._send_ca_post(path='enroll',
File "/home/yusen/Desktop/fabric-sdk-py/hfc/fabric_ca/caservice.py", line 255, in _send_ca_post
return r.json(), r.status_code
File "/home/yusen/anaconda3/lib/python3.8/site-packages/requests/models.py", line 889, in json
return complexjson.loads(
File "/home/yusen/anaconda3/lib/python3.8/json/init.py", line 357, in loads
return _default_decoder.decode(s)
File "/home/yusen/anaconda3/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/home/yusen/anaconda3/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Build failure due to cryptography 3.4.7

The farbic-py-sdk is unable to build on CentOS 8.0.
While processing dependencies for fabric-py-sdk==0.9.0, the build looks for cryptography>=1.9 and ends up on version 3.4.7. The corresponding setup.py throws a error.

Logs below for the error scenario -

[2021-06-30T14:04:42.635Z] Searching for cryptography>=1.9
[2021-06-30T14:04:42.635Z] Reading https://pypi.org/simple/cryptography/
[2021-06-30T14:04:44.060Z] Downloading https://files.pythonhosted.org/packages/9b/77/461087a514d2e8ece1c975d8216bc03f7048e6090c5166bc34115afdaa53/cryptography-3.4.7.tar.gz#sha256=3d10de8116d25649631977cb37da6cbdd2d6fa0e0281d014a5b7d337255ca713
[2021-06-30T14:04:44.331Z] Best match: cryptography 3.4.7
[2021-06-30T14:04:44.331Z] Processing cryptography-3.4.7.tar.gz
[2021-06-30T14:04:44.331Z] Writing /tmp/easy_install-tgr1m2va/cryptography-3.4.7/setup.cfg
[2021-06-30T14:04:44.331Z] Running cryptography-3.4.7/setup.py -q bdist_egg --dist-dir /tmp/easy_install-tgr1m2va/cryptography-3.4.7/egg-dist-tmp-7b5pxrsu
[2021-06-30T14:04:44.768Z]
[2021-06-30T14:04:44.768Z] =============================DEBUG ASSISTANCE==========================
[2021-06-30T14:04:44.768Z] If you are seeing an error here please try the following to
[2021-06-30T14:04:44.768Z] successfully install cryptography:
[2021-06-30T14:04:44.768Z]
[2021-06-30T14:04:44.768Z] Upgrade to the latest pip and try again. This will fix errors for most
[2021-06-30T14:04:44.768Z] users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
[2021-06-30T14:04:44.768Z] =============================DEBUG ASSISTANCE==========================
[2021-06-30T14:04:44.768Z]
[2021-06-30T14:04:44.768Z] �[91mTraceback (most recent call last):
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/sandbox.py", line 154, in save_modules
[2021-06-30T14:04:44.768Z] yield saved
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/sandbox.py", line 195, in setup_context
[2021-06-30T14:04:44.768Z] yield
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/sandbox.py", line 250, in run_setup
[2021-06-30T14:04:44.768Z] _execfile(setup_script, ns)
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/sandbox.py", line 45, in _execfile
[2021-06-30T14:04:44.768Z] exec(code, globals, locals)
[2021-06-30T14:04:44.768Z] File "/tmp/easy_install-tgr1m2va/cryptography-3.4.7/setup.py", line 14, in
[2021-06-30T14:04:44.768Z] with open('./requirements.txt') as reqs_txt:
[2021-06-30T14:04:44.768Z] ModuleNotFoundError: No module named 'setuptools_rust'
[2021-06-30T14:04:44.768Z]
[2021-06-30T14:04:44.768Z] During handling of the above exception, another exception occurred:
[2021-06-30T14:04:44.768Z]
[2021-06-30T14:04:44.768Z] Traceback (most recent call last):
[2021-06-30T14:04:44.768Z] File "setup.py", line 46, in
[2021-06-30T14:04:44.768Z] include_package_data=True,
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/init.py", line 129, in setup
[2021-06-30T14:04:44.768Z] return distutils.core.setup(**attrs)
[2021-06-30T14:04:44.768Z] File "/usr/lib64/python3.6/distutils/core.py", line 148, in setup
[2021-06-30T14:04:44.768Z] dist.run_commands()
[2021-06-30T14:04:44.768Z] File "/usr/lib64/python3.6/distutils/dist.py", line 955, in run_commands
[2021-06-30T14:04:44.768Z] self.run_command(cmd)
[2021-06-30T14:04:44.768Z] File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
[2021-06-30T14:04:44.768Z] cmd_obj.run()
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/command/install.py", line 67, in run
[2021-06-30T14:04:44.768Z] self.do_egg_install()
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/command/install.py", line 117, in do_egg_install
[2021-06-30T14:04:44.768Z] cmd.run()
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 411, in run
[2021-06-30T14:04:44.768Z] self.easy_install(spec, not self.no_deps)
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 659, in easy_install
[2021-06-30T14:04:44.768Z] return self.install_item(None, spec, tmpdir, deps, True)
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 706, in install_item
[2021-06-30T14:04:44.768Z] self.process_distribution(spec, dist, deps)
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 751, in process_distribution
[2021-06-30T14:04:44.768Z] [requirement], self.local_index, self.easy_install
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 770, in resolve
[2021-06-30T14:04:44.768Z] replace_conflicting=replace_conflicting
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 1053, in best_match
[2021-06-30T14:04:44.768Z] return self.obtain(req, installer)
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 1065, in obtain
[2021-06-30T14:04:44.768Z] return installer(requirement)
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 678, in easy_install
[2021-06-30T14:04:44.768Z] return self.install_item(spec, dist.location, tmpdir, deps)
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 704, in install_item
[2021-06-30T14:04:44.768Z] dists = self.install_eggs(spec, download, tmpdir)
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 889, in install_eggs
[2021-06-30T14:04:44.768Z] return self.build_and_install(setup_script, setup_base)
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 1157, in build_and_install
[2021-06-30T14:04:44.768Z] self.run_setup(setup_script, setup_base, args)
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 1143, in run_setup
[2021-06-30T14:04:44.768Z] run_setup(setup_script, args)
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/sandbox.py", line 253, in run_setup
[2021-06-30T14:04:44.768Z] raise
[2021-06-30T14:04:44.768Z] File "/usr/lib64/python3.6/contextlib.py", line 99, in exit
[2021-06-30T14:04:44.768Z] self.gen.throw(type, value, traceback)
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/sandbox.py", line 195, in setup_context
[2021-06-30T14:04:44.768Z] yield
[2021-06-30T14:04:44.768Z] File "/usr/lib64/python3.6/contextlib.py", line 99, in exit
[2021-06-30T14:04:44.768Z] self.gen.throw(type, value, traceback)
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/sandbox.py", line 166, in save_modules
[2021-06-30T14:04:44.768Z] saved_exc.resume()
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/sandbox.py", line 141, in resume
[2021-06-30T14:04:44.768Z] six.reraise(type, exc, self._tb)
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/_vendor/six.py", line 685, in reraise
[2021-06-30T14:04:44.768Z] raise value.with_traceback(tb)
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/sandbox.py", line 154, in save_modules
[2021-06-30T14:04:44.768Z] yield saved
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/sandbox.py", line 195, in setup_context
[2021-06-30T14:04:44.768Z] yield
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/sandbox.py", line 250, in run_setup
[2021-06-30T14:04:44.768Z] _execfile(setup_script, ns)
[2021-06-30T14:04:44.768Z] File "/usr/lib/python3.6/site-packages/setuptools/sandbox.py", line 45, in _execfile
[2021-06-30T14:04:44.768Z] exec(code, globals, locals)
[2021-06-30T14:04:44.768Z] File "/tmp/easy_install-tgr1m2va/cryptography-3.4.7/setup.py", line 14, in
[2021-06-30T14:04:44.768Z] with open('./requirements.txt') as reqs_txt:
[2021-06-30T14:04:44.768Z] ModuleNotFoundError: No module named 'setuptools_rust'
[2021-06-30T14:04:44.768Z] �[0m�[91mmake: *** [Makefile:85: install] Error 1

Improve (API) documentation

Hi all, I am trying to use Sphinx autodoc function/extension, so I need to improve the current documentation of hfc. I will update the information on this issue later.

Response of chaincode_invoke is empty

Hello, I'm trying to use fabric-sdk-py to operate Chaincodes on my Fabric Network, but when I invoke chaincode I get an empty response.

First, I build my Fabric Network simply based on first-network, only replace the domain name 'example.com' to 'srtp.com'. Then I follow the Tutorial.ipynb and Tutorial.md to get started.

Everything goes well until I invoke the chaincode, I got an empty response like this:

# Invoke a chaincode
args = ["set", "1", "2019/12/1", "619", "1", "32.14"]
# The response should be true if succeed
response = loop.run_until_complete(cli.chaincode_invoke(
               requestor=org1_admin,
               channel_name='mychannel',
               peers=['peer0.org1.srtp.com'],
               args=args,
               wait_for_event=True,
               cc_name='srtp'))
response

----------------------------------
''

Then I check the Fabric Network in cli bash, I find that the chaincode was installed. I try to invoke the chaincode by peer command(peer chaincode invoke.....), and it works, but I find if I use command peer chaincode query it returns error like this:

Error: endorsement failure during query. response: status:500 message:"\345\234\250get()\345\207\275\346\225\260\344\270\255\346\212\245\351\224\231: \346\240\271\346\215\256 1 \346\234\252\350\203\275\350\216\267\345\217\226\345\210\260\347\273\223\346\236\234"

It works well when I totally use command to operate the Fabric Network.

So I guess the problem occurred when I instantiate chaincode. This is the code and response:

from hfc.util.policies import s2d

# Instantiate Chaincode in Channel, the response should be true if succeed
args = ["1", "2019/12/1", "617", "1", "44.14"]

# This policy specifies the endorsement policy which is required while instantiating the chaincode
policy = s2d().parse("OR('Org1MSP.member', 'Org2MSP.member')")
# policy = s2d().parse("OR('Org1MSP.peer')")

response = loop.run_until_complete(cli.chaincode_instantiate(
               requestor=org1_admin,
               channel_name='mychannel',
               peers=['peer0.org1.srtp.com'],
               args=args,
               cc_name='srtp',
               cc_version='v1.0',
               cc_endorsement_policy=policy, # optional, but recommended
               collections_config=None, # optional, for private data policy
               transient_map=None, # optional, for private data
               wait_for_event=True # optional, for being sure chaincode is instantiated
               ))
response

--------------------------------------
context [TXContext:_tx_prop_req=<hfc.fabric.transaction.tx_proposal_request.TXProposalRequest object at 0x7f21ac017f28>,_user=[User:_name=Admin,_org=org1.srtp.com,_state_store=[FileKeyValueStore:path=/tmp/hfc-kvs],_state_store_key=user.Admin.org1.srtp.com,_roles=[],_account=None,_affiliation=None,_enrollment_secret=None,_enrollment=[Enrollment:_service=None,_private_key=<cryptography.hazmat.backends.openssl.ec._EllipticCurvePrivateKey object at 0x7f21ad4bf908>,_cert=b'-----BEGIN CERTIFICATE-----\nMIICIDCCAcegAwIBAgIQWIUquMZ0HbJJhXaDNZUKDTAKBggqhkjOPQQDAjBtMQsw\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy\nYW5jaXNjbzEWMBQGA1UEChMNb3JnMS5zcnRwLmNvbTEZMBcGA1UEAxMQY2Eub3Jn\nMS5zcnRwLmNvbTAeFw0yMTA0MTAwMzM5MDBaFw0zMTA0MDgwMzM5MDBaMGkxCzAJ\nBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJh\nbmNpc2NvMQ8wDQYDVQQLEwZjbGllbnQxHDAaBgNVBAMME0FkbWluQG9yZzEuc3J0\ncC5jb20wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARojwa1Y1aVCnxPwuPuhE55\nQrhYkB/zazkeUn0CCOBMuPiARcgPjEJH0KHv/AV1UR+GKSmUqXk9SQXd5BK38aiL\no00wSzAOBgNVHQ8BAf8EBAMCB4AwDAYDVR0TAQH/BAIwADArBgNVHSMEJDAigCCQ\nvz92KKY7ng4LEVKIZFo6HWA3gqHC2XYoZhkN/ZSQMTAKBggqhkjOPQQDAgNHADBE\nAiA4mcRRAWi4m+MllHlbUEdZwYLgOqRG2zUBs56R6hnpWQIgPGInLcov/YO6Vnhw\nS4yPLPYvkKkdYtvokxGT4c/J0Ek=\n-----END CERTIFICATE-----\n',_caCert=None],_msp_id=Org1MSP,_cryptoSuite=<hfc.util.crypto.crypto.Ecies object at 0x7f21c4434358>],_crypto=<hfc.util.crypto.crypto.Ecies object at 0x7f21c4434358>,_identity=b'\n\x07Org1MSP\x12\x9e\x06-----BEGIN CERTIFICATE-----\nMIICIDCCAcegAwIBAgIQWIUquMZ0HbJJhXaDNZUKDTAKBggqhkjOPQQDAjBtMQsw\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy\nYW5jaXNjbzEWMBQGA1UEChMNb3JnMS5zcnRwLmNvbTEZMBcGA1UEAxMQY2Eub3Jn\nMS5zcnRwLmNvbTAeFw0yMTA0MTAwMzM5MDBaFw0zMTA0MDgwMzM5MDBaMGkxCzAJ\nBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJh\nbmNpc2NvMQ8wDQYDVQQLEwZjbGllbnQxHDAaBgNVBAMME0FkbWluQG9yZzEuc3J0\ncC5jb20wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARojwa1Y1aVCnxPwuPuhE55\nQrhYkB/zazkeUn0CCOBMuPiARcgPjEJH0KHv/AV1UR+GKSmUqXk9SQXd5BK38aiL\no00wSzAOBgNVHQ8BAf8EBAMCB4AwDAYDVR0TAQH/BAIwADArBgNVHSMEJDAigCCQ\nvz92KKY7ng4LEVKIZFo6HWA3gqHC2XYoZhkN/ZSQMTAKBggqhkjOPQQDAgNHADBE\nAiA4mcRRAWi4m+MllHlbUEdZwYLgOqRG2zUBs56R6hnpWQIgPGInLcov/YO6Vnhw\nS4yPLPYvkKkdYtvokxGT4c/J0Ek=\n-----END CERTIFICATE-----\n',_nonce=b'\xd4\xc8\xb2\x06B\xe7\xfabS/\x91\xe36F\xc9\x8e#2ba\xaeQ\xef\x15',_tx_id=6fae5caaf2dd92db690386502dc4306483501f1cdf5082ce069da22f27202cc4,_prop_wait_time=-1]
{'name': 'srtp',
 'version': 'v1.0',
 'escc': 'escc',
 'vscc': 'vscc',
 'policy': {'version': 0,
  'rule': {'n_out_of': {'n': 1,
    'rules': [{'signed_by': 0}, {'signed_by': 1}]}},
  'identities': [{'principal_classification': 'ROLE',
    'principal': {'msp_identifier': 'Org1MSP', 'role': 'MEMBER'}},
   {'principal_classification': 'ROLE',
    'principal': {'msp_identifier': 'Org2MSP', 'role': 'MEMBER'}}]},
 'data': {'hash': b'\xb0\xd8L\xe7\xd7\x9d\xa4\xa0m\xe4\xc2j\xcd\x10m\xbcw\xe2\x9d\xfe+s\xa7e\xc5R\x98kS=\x0eF',
  'metadatahash': b'\x92\x97\x1c\xbfR\xadE\xd7%\xb5\x9c?+\xcaD\xaeq,\x05\xf8\xb0\xcb\xd6J\xc3\xfbo\xc7\x85\x86\xb6@'},
 'id': b'\xe2m\x07\xe06n]"\'o\r\xe1\xa0\x83\xb5&z\xf43\xe3P\xe5S\xff\xaa\xc9\x91$\xfep\\\x1b',
 'instantiation_policy': {'version': 0,
  'rule': {'n_out_of': {'n': 1,
    'rules': [{'signed_by': 0}, {'signed_by': 1}]}},
  'identities': [{'principal_classification': 'ROLE',
    'principal': {'msp_identifier': 'Org1MSP', 'role': 'ADMIN'}},
   {'principal_classification': 'ROLE',
    'principal': {'msp_identifier': 'Org2MSP', 'role': 'ADMIN'}}]}}

Could you tell me what's wrong with my code or my network? Thank you so much!

When I use the CA server and enroll successfully locally, how can I use it next? For example, Query Peer installed chaincodes? Can you post the code for an example?

When I use the CA server and enroll successfully locally, how can I use it next? For example, Query Peer installed chaincodes? Can you post the code for an example?

`from hfc.fabric_ca.caservice import ca_service
from hfc.fabric import Client

casvc = ca_service(target="http://192.168.1.106:7054")
adminEnrollment = casvc.enroll("admin", "adminpw") # now local will have the admin enrollment
secret = adminEnrollment.register("user1") # register a user to ca
user1Enrollment = casvc.enroll("user1", secret) # now local will have the user enrollment`

local test failed for couchdbwalletstore

For Azure pipelines, I've made an external service for couchdb, but locally the build will fail if I do not install couchdb manually. I think we should use a docker instance for a local couchdbwalletstore test as well.
image

unable to use "first-network" network.json file with python sdk

create org with name=Org1
create ca with name=ca.org1.fabricfl.com
No key path ('orderers',) exists in net info
Traceback (most recent call last):
File "", line 1, in
File "/Users/viraajimothukuri/fabric-sdk-py/hfc/fabric/client.py", line 76, in init
self.init_with_net_profile(net_profile)
File "/Users/viraajimothukuri/fabric-sdk-py/hfc/fabric/client.py", line 116, in init_with_net_profile
_logger.debug("Import orderers = {}".format(orderers.keys()))
AttributeError: 'NoneType' object has no attribute 'keys'

Request for help

Hello, I have built and run the following code and an error has occurred, I hope you can answer it. (Code and error message below) Thank you very much
image
image

fail to get genesis block

My fabric-version is 2.0, python-version is 3.7. How can I what to do? The fabric network is running.

Traceback (most recent call last):
File "train.py", line 33, in
orderer='orderer.example.com'
File "/usr/local/python3/lib/python3.7/asyncio/base_events.py", line 568, in run_until_complete
return future.result()
File "/usr/local/python3/lib/python3.7/site-packages/fabric_sdk_py-0.9.0-py3.7.egg/hfc/fabric/client.py", line 654, in channel_join
raise Exception(msg)
Exception: fail to get genesis block

Please help me! Thanks a lot!

How can I retrieve user identity?

Hi,

Following manual instructions I can create a user and store the identity in e.g., FileSystenWallet. However, I need to recover that identity in a different code location. I have tried:

user1_cert = wallet.Identity("user1", user1Enrollment)._EnrollmentCert, but it depends of user1Enrollment , so I get an error that the user has been registered.

res = identityService.getOne('user1', admin), allows to recover information of user1 but no the certified to e.g. query the blockchain,

image

Thanks in advance.

Add support for trio

Looks like the sdk currently supports asyncio. Is it possible to add support for trio? That would be very helpful for trio users.

This page don't exits.

When I click on link that https://fabric-sdk-py.readthedocs.io/en/latest/test/fixtures/network.json displaying don't exits.
It is link that come from https://fabric-sdk-py.readthedocs.io/en/latest/tutorial.html content in the website

Support cert/private keys as string in connection profile

The connection profile (network.json) supports specifying certs and private keys as a path.

Similarly to what the NodeJS sdk client provides (https://github.com/hyperledger/fabric-sdk-node/blob/master/test/fixtures/profiles/network.json#L49) it would be useful to allow specifying the certificates contents directly as strings, e.g.

      "users": {
        "Admin": {
          "cert_pem": "-----BEGIN CERTIFICATE-----\nMIIB+zCCAaGgAwIBAgIUSFaxTErz/QK2xfiFuHR3km8cNFowCgYIKoZIzj0EAwIw\nWjELMAkGA1UEBhMCVVMxFzAVBgNVBAgTDk5vcn ... n-----END CERTIFICATE-----"
          "private_key_pem": "-----BEGIN PRIVATE KEY-----\nMIGHAgEAM ... 5zIHXyi2yB+hWxJ\n-----END PRIVATE KEY-----"
        }
      }

[...]

      "tlsCACerts": {
        "pem": "-----BEGIN CERTIFICATE-----\nMIIB+zCCAaGgAwIBAgIUSFaxTErz/QK2xfiFuHR3km8cNFowCgYIKoZIzj0EAwIw\nWjELMAkGA1UEBhMCVVMxFzAVBgNVBAgTDk5vcn ... n-----END CERTIFICATE-----"
      },

Annotation mistake in Tutorial.ipynb

Hi
There is a little mistake in Tutorial.ipynb. Above block [5], the annotation says Run the below code snippet to make the peers of Org1 join the channel. Actually, block [5] adds peers of Org2 into the channel.

😃

Ask on chaincode install error

Hi, I was trying to install some chaincode into a created channel, just as in the tutorial documentation.

    response = await cli.chaincode_install(
        requestor=org1_admin,
        peers=['peer0.org1.example.com', 'peer1.org1.example.com'],
        cc_path='github.com/example_cc',
        cc_name='example_cc',
        cc_version='v1.0')

But got the following report back.

  File "fabric-exp.py", line 71, in async_main
    response = await cli.chaincode_install(
  File "/home/wul4/sofie/projects/interledger/il-dev/lib/python3.8/site-packages/fabric_sdk_py-0.8.1-py3.8.egg/hfc/fabric/client.py", line 1188, in chaincode_install
    responses, proposal, header = self.send_install_proposal(tx_context,
  File "/home/wul4/sofie/projects/interledger/il-dev/lib/python3.8/site-packages/fabric_sdk_py-0.8.1-py3.8.egg/hfc/fabric/client.py", line 1074, in send_install_proposal
    return utils.send_install_proposal(tx_context, peers)
  File "/home/wul4/sofie/projects/interledger/il-dev/lib/python3.8/site-packages/fabric_sdk_py-0.8.1-py3.8.egg/hfc/util/utils.py", line 400, in send_install_proposal
    package_chaincode(
  File "/home/wul4/sofie/projects/interledger/il-dev/lib/python3.8/site-packages/fabric_sdk_py-0.8.1-py3.8.egg/hfc/util/utils.py", line 500, in package_chaincode
    dist.addfile(tarinfo, f)
  File "/home/wul4/sofie/projects/interledger/il-dev/lib/python3.8/tarfile.py", line 1989, in addfile
    buf = tarinfo.tobuf(self.format, self.encoding, self.errors)
  File "/home/wul4/sofie/projects/interledger/il-dev/lib/python3.8/tarfile.py", line 826, in tobuf
    return self.create_pax_header(info, encoding)
  File "/home/wul4/sofie/projects/interledger/il-dev/lib/python3.8/tarfile.py", line 900, in create_pax_header
    buf = self._create_pax_generic_header(pax_headers, XHDTYPE, encoding)
  File "/home/wul4/sofie/projects/interledger/il-dev/lib/python3.8/tarfile.py", line 994, in _create_pax_generic_header
    value.encode("utf-8", "strict")
AttributeError: 'int' object has no attribute 'encode'
Exception ignored in: <function _Stream.__del__ at 0x7f14cde99700>
Traceback (most recent call last):
  File "/home/wul4/sofie/projects/interledger/il-dev/lib/python3.8/tarfile.py", line 410, in __del__
  File "/home/wul4/sofie/projects/interledger/il-dev/lib/python3.8/tarfile.py", line 458, in close
ValueError: I/O operation on closed file.

Is there any further setup required? Or any other reasons that might cause such problems?

Can the CA of the network profile become optional?

Some test networks don't have the CA. To execute the SDK test, you must comment the code that loads the CA configuration first

# Init CAs
cas = self.get_net_info('certificateAuthorities')
for name in cas:
    _logger.debug("create ca with name={}".format(name))
     ca = create_ca(name, cas[name])
     self._CAs[name] = ca

"Missing 'proposalResponses' parameter in transaction request"

I recently started learning fabric and wrote a small demo, but there were errors when uploading data using postman. When I upload the following data, the code will not make mistakes.But when the data I upload is 15M, an error will be reported,"Missing 'proposalResponses' parameter in transaction request"。here is the data

{
    "identifier": "client0_to_rsu4_epoch1",
    "data": {
        "enc_vectors": {
            "conv1.weight": "conv1.weightxxxxxxxxxxx",
            "conv1.bias": "conv1.biasxxxxx",
            "conv2.weight": "conv2.weightxxx",
            "conv2.bias": "conv2.biasxxxxxx",
            "fc1.weight": "fc1.weightxxxxx",
            "fc1.bias": "fc1.biasxxxx",
            "fc2.weight": "fc2.weightxxxxxxx",
            "fc2.bias": "fc2.biasxxxx"
        },
        "dec_aes_key": "chBXLZA03PXYzs43UArhGfGsSn7TACdldFIqYPTO3/FjS73h50IX4RSoALE13fqkROEray0lsLiShIN/48exerGDEaL0BN6O0gGpq55WwNtRUqrsOvGzwisFLJVGK3d5nCyo+Hw8QwjO4fwfQs2ynpeubP1+Zr/TIx09p4NDUHM=",
        "loss_slice": 0.10846090443590854
    }
}

The following is the data displayed in the docker log

docker logs dev-peer1.org1.example.com-privacy_cc-1.0
invoke is runningadd
进入add函数
反序列化中
根据Id获取值
添加数据
序列化数据
保存数据
发送事件

I wonder if this problem occurs because the uploaded data is too large.

I tried to change PreferredMaxBytes from 512KB to 15MB, but it didn't work.

Is there any way for me to upload such large data?

pip-audit shows issues

pip-audit found one or more problems

Name Version ID Fix Versions Description


cryptography 2.8 PYSEC-2021-62 3.2.1 python-cryptography 3.2 is vulnerable to Bleichenbacher timing attacks in the RSA decryption API, via timed processing of valid PKCS#1 v1.5 ciphertext.
httplib2 0.14.0 PYSEC-2020-46 0.18.0 In httplib2 before version 0.18.0, an attacker controlling unescaped part of uri for httplib2.Http.request() could change request headers and body, send additional hidden requests to same server. This vulnerability impacts software that uses httplib2 with uri constructed by string concatenation, as opposed to proper urllib building with escaping. This has been fixed in 0.18.0.
httplib2 0.14.0 PYSEC-2021-16 0.19.0 httplib2 is a comprehensive HTTP client library for Python. In httplib2 before version 0.19.0, a malicious server which responds with long series of "\xa0" characters in the "www-authenticate" header may cause Denial of Service (CPU burn while parsing header) of the httplib2 client accessing said server. This is fixed in version 0.19.0 which contains a new implementation of auth headers parsing using the pyparsing library.
jinja2 2.10.1 PYSEC-2021-66 2.11.3 This affects the package jinja2 from 0.0.0 and before 2.11.3. The ReDoS vulnerability is mainly due to the _punctuation_re regex operator and its use of multiple wildcards. The last wildcard is the most exploitable as it searches for trailing punctuation. This issue can be mitigated by Markdown to format user content instead of the urlize filter, or by implementing request timeouts and limiting process memory.
pip 20.0.2 PYSEC-2021-437 21.1 A flaw was found in python-pip in the way it handled Unicode separators in git references. A remote attacker could possibly use this issue to install a different revision on a repository. The highest threat from this vulnerability is to data integrity. This is fixed in python-pip version 21.1.
protobuf 3.6.1 PYSEC-2022-48 3.15.0 Nullptr dereference when a null char is present in a proto symbol. The symbol is parsed incorrectly, leading to an unchecked call into the proto file's name during generation of the resulting error message. Since the symbol is incorrectly parsed, the file is nullptr. We recommend upgrading to version 3.15.0 or greater.
pyjwt 1.7.1 PYSEC-2022-202 2.4.0 PyJWT is a Python implementation of RFC 7519. PyJWT supports multiple different JWT signing algorithms. With JWT, an attacker submitting the JWT token can choose the used signing algorithm. The PyJWT library requires that the application chooses what algorithms are supported. The application can specify jwt.algorithms.get_default_algorithms() to get support for all algorithms, or specify a single algorithm. The issue is not that big as algorithms=jwt.algorithms.get_default_algorithms() has to be used. Users should upgrade to v2.4.0 to receive a patch for this issue. As a workaround, always be explicit with the algorithms that are accepted and expected when decoding.
pyyaml 5.3.1 PYSEC-2021-142 5.4 A vulnerability was discovered in the PyYAML library in versions before 5.4, where it is susceptible to arbitrary code execution when it processes untrusted YAML files through the full_load method or with the FullLoader loader. Applications that use the library to process untrusted input may be vulnerable to this flaw. This flaw allows an attacker to execute arbitrary code on the system by abusing the python/object/new constructor. This flaw is due to an incomplete fix for CVE-2020-1747.
twisted 18.9.0 PYSEC-2019-128 19.2.1 In Twisted before 19.2.1, twisted.web did not validate or sanitize URIs or HTTP methods, allowing an attacker to inject invalid characters such as CRLF.
twisted 18.9.0 PYSEC-2020-260 20.3.0rc1 In Twisted Web through 19.10.0, there was an HTTP request splitting vulnerability. When presented with a content-length and a chunked encoding header, the content-length took precedence and the remainder of the request body was interpreted as a pipelined request.
twisted 18.9.0 PYSEC-2019-129 19.7.0rc1 In words.protocols.jabber.xmlstream in Twisted through 19.2.1, XMPP support did not verify certificates when used with TLS, allowing an attacker to MITM connections.
twisted 18.9.0 PYSEC-2020-259 20.3.0rc1 In Twisted Web through 19.10.0, there was an HTTP request splitting vulnerability. When presented with two content-length headers, it ignored the first header. When the second content-length value was set to zero, the request body was interpreted as a pipelined request.
twisted 18.9.0 PYSEC-2022-27 22.1.0 twisted is an event-driven networking engine written in Python. In affected versions twisted exposes cookies and authorization headers when following cross-origin redirects. This issue is present in the twited.web.RedirectAgent and twisted.web. BrowserLikeRedirectAgent functions. Users are advised to upgrade. There are no known workarounds.
twisted 18.9.0 PYSEC-2022-195 22.4.0 Twisted is an event-based framework for internet applications, supporting Python 3.6+. Prior to version 22.4.0rc1, the Twisted Web HTTP 1.1 server, located in the twisted.web.http module, parsed several HTTP request constructs more leniently than permitted by RFC 7230. This non-conformant parsing can lead to desync if requests pass through multiple HTTP parsers, potentially resulting in HTTP request smuggling. Users who may be affected use Twisted Web's HTTP 1.1 server and/or proxy and also pass requests through a different HTTP server and/or proxy. The Twisted Web client is not affected. The HTTP 2.0 server uses a different parser, so it is not affected. The issue has been addressed in Twisted 22.4.0rc1. Two workarounds are available: Ensure any vulnerabilities in upstream proxies have been addressed, such as by upgrading them; or filter malformed requests by other means, such as configuration of an upstream proxy.
twisted 18.9.0 GHSA-32gv-6cf3-wcmq 19.10.0 ### Impact
Twisted web servers that utilize the optional HTTP/2 support suffer from the following flow-control related vulnerabilities:

Ping flood: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-9512
Reset flood: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-9514
Settings flood: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-9515

A Twisted web server supports HTTP/2 requests if you've installed the http2 optional dependency set.

Workarounds

There are no workarounds.

References

https://github.com/Netflix/security-bulletins/blob/master/advisories/third-party/2019-002.md

Channel config decoding issue

Hi,
I'm having an issue with fetch of the config block for a channel, for some reason when fetching config block using python sdk config part /channel_group/groups/Orderer/values/ConsensusType/value doesn't have metadata/consenters field. It seems to be an issue with protobuf decoding because if I fetch application channel config without decoding everything is in place, but get_channel_config_with_orderer doesn't allow fetch of the system channel config without decoding. Can anyone comment on this if this is known issue or maybe I'm doing something wrong?

ModuleNotFoundError: No module named 'google'

At present, I am studying fabric-sdk-py.According to the manual, I used

$ git clone https://github.com/hyperledger/fabric-sdk-py.git
$ cd fabric-sdk-py
$ make install

to pull the fabric-sdk-python in GitHub. Then,I downloaded pycharm in Ubuntu18.4 and imported the extracted fabric-sdk-py.I created test.py under this fabric-sdk-py, which I want to test create and join channel by sdk. But I compiled the following error:

/root/PycharmProjects/pythonProject/venv/bin/python /root/fabric-sdk-py/test.py

Traceback (most recent call last):
  File "/root/fabric-sdk-py/test.py", line 2, in <module>
    from hfc.fabric import Client
  File "/root/fabric-sdk-py/hfc/fabric/__init__.py", line 6, in <module>
    from .client import Client  # noqa
  File "/root/fabric-sdk-py/hfc/fabric/client.py", line 16, in <module>
    from hfc.fabric.channel.channel import Channel
  File "/root/fabric-sdk-py/hfc/fabric/channel/channel.py", line 10, in <module>
    from hfc.protos.msp import msp_principal_pb2
  File "/root/fabric-sdk-py/hfc/protos/msp/msp_principal_pb2.py", line 5, in <module>
    from google.protobuf import descriptor as _descriptor
ModuleNotFoundError: No module named 'google'

Process finished with exit code 1

I pulled it many times. and tried the following solutions.

1.conda install protobuf

2.pip uninstall protobuf
 pip uninstall google
pip install google
pip install protobuf

3、pip install --upgrade google-api-python-client

4.pip install google-cloud    
pip install google-cloud-vision

But the problem has not been solved.My version is fabric 1.4 and python 3.8.5.
Please help me, thank you very much.

Addition of pre-commit

@dexhunter
Since this repo contains python code, I thought maybe we can have a sort of rule check in the form of pre-commit config, which can help us maintain the code quality before someone raises a PR. The already existing lint test configurations can be used for having a pre-commit.
If it's something that you feel we can add, please let me know. I can work on this!
Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.