hyperledger / fabric-sdk-py

Hyperledger Fabric Python SDK
https://fabric-sdk-py.readthedocs.io/en/latest/
Apache License 2.0
405 stars 200 forks source link

Error Generating Channel Configuration and Joining Channel: Issues with Policies and Application Capability #193

Open AndrezaNobrega opened 2 months ago

AndrezaNobrega commented 2 months ago

I am experiencing an issue while generating and handling channel configurations using the Python SDK for Hyperledger Fabric. Here are the details of the problem:

  1. Error Generating Channel Transaction File: When trying to create a channel using the Python SDK, I receive an error related to the configtx.yaml configuration. The error indicates that the configuration is incorrect, specifically "no policies defined" and "could not generate default config template". The full error message is:

    Error on outputChannelCreateTx: could not generate default config template: error parsing configuration: error adding policies to channel group: no policies defined
  2. Modifications Made: I modified the configtx.yaml file to define appropriate policies and permissions. The updated file is as follows (relevant part):

    Policies:
       Readers:
           Type: ImplicitMeta
           Rule: "ANY Readers"
       Writers:
           Type: ImplicitMeta
           Rule: "ANY Writers"
       Admins:
           Type: ImplicitMeta
           Rule: "ANY Admins"
  3. Problem Joining Peers to the Channel: Even after modification, when the peers try to join the channel, they are being kicked out and the following error message is displayed:

    WARNING:hfc.fabric.client:channel businesschannel not existed when join

    Additional Logs:

    After making the changes, when trying to join the peers to the channel, I received the following log error:

    Traceback (most recent call last):
     File "test_sdk.py", line 132, in <module>
       loop.run_until_complete(main())
     File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
       return future.result()
     File "test_sdk.py", line 42, in main
       responses = await cli.channel_join(
     File "/usr/local/lib/python3.8/dist-packages/fabric_sdk_py-0.9.0-py3.8.egg/hfc/fabric/client.py", line 695, in channel_join
       res = await asyncio.gather(*responses)
     File "/usr/local/lib/python3.8/dist-packages/aiogrpc-1.8-py3.8.egg/aiogrpc/channel.py", line 40, in __call__
       return await fut
    grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
           status = StatusCode.UNAVAILABLE
           details = "Socket closed"
           debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2024-08-17T18:17:30.161570647-03:00", grpc_status:14, grpc_message:"Socket closed"}"

    And on the node, it was logged as:

    2024-08-17 21:17:30.155 UTC [peer] capabilitiesSupportedOrPanic -> PANI 27f [channel businesschannel] incompatible: Application capability V2_0 is required but not supported
    panic: [channel businesschannel] incompatible: Application capability V2_0 is required but not supported
           panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x13d9f2d]
    goroutine 199 [running]:
    github.com/hyperledger/fabric/core/chaincode/shim.(*Handler).triggerNextState(0xc00262d4a0, 0x0, 0xc0003ad140)
  4. Command Used: The command used to join the peers to the channel was as follows:

    # For operations on peers from org2.example.com, org2_admin is required as requestor
    print('to make the peers of Org1 join the channel.')
    responses = await cli.channel_join(
       requestor=org1_admin,
       channel_name='businesschannel',
       peers=['peer0.org1.example.com',
       'peer1.org1.example.com'],
       orderer='orderer.example.com'
    )
    
    print('response from request to Org1 join to the channel: ')
    print(len(responses) == 2)

Expected Outcome:

The channel should be created successfully, and the peers should be able to join the channel without errors.

Environment:

Logs:

The displayed error logs are as follows:

File "/usr/lib/python3.8/logging/__init__.py", line 929, in format
    return fmt.format(record)
  File "/usr/lib/python3.8/logging/__init__.py", line 668, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.8/logging/__init__.py", line 373, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
...

Thank you in advance for your assistance with this issue.