setup multi-org fabric network using peer dev mode


satheesh
 

Hello Community,

Using Hyperledger fabric 2.4

While working on a Hyperledger Fabric use case,  realized that setting up a environment where peer can be run in
development mode (peer node start --peer-chaincodedev=true) is quite fast to iterate chaincode development.

Official documentation provides material to setup up such environment but for only one org.
But if we want to setup a multi-org consortium using peer development mode, Is there any reference material
available ? Appreciate any pointers.

Regards,
Satheesh


David Faulstich Diniz Reis
 

Hello Satheesh. How are you? I hope you are doing well.

My personal dev environment is using the CCAAS builders that came with 2.4+ version with vagrant and connecting remotely using an IDE (VSCODE or IntelliJ).

If you are using fabric samples, you just need change all of your peers to start with --peer-chaincodedev=true ( YAML line with command: peer node start --peer-chaincodedev=true - compose-test-net.yaml) and start your network to be able to debug.

In my case, when I am developing the chaincode, I start the chaincode using my IDE using the command:

-  "start:server-debug": "set -x && NODE_OPTIONS='--inspect=0.0.0.0:9229' fabric-chaincode-node server --chaincode-address=$CHAINCODE_SERVER_ADDRESS --chaincode-id=$CHAINCODE_ID",

  • The variable CHAINCODE_SERVER_ADDRESS is the same as "address" key of the connection.json (Ex.: mycoolchaincode.myserver.org:9998 and configure the /etc/hosts to resolve this dns when needed or use https://nip.io/ solution to get correct DNS resolution).
  • The variable CHAINCODE_ID may be obtained during install command;

The chaincode package that will be installed in all peers, I generate using the following commands (I am using Javascript / Typescript chaincodes):

  • tar cfz code.tar.gz connection.json ../META-INF
  • tar cfz mycoolchaincode.tgz metadata.json code.tar.gz
(I do the install  in all peers if needed);

NOTE: with this setup, all peers will use only one chaincode endpoint (running attached to IDE).

And finally, I change the endorsement rule to need only one endorsement and the peers execute only one time the chaincode. In a multi org, the breakpoint will get accessed a lot of times, turning the debug process a little more difficult:
  • --signature-policy "OR('Org1MSP.member', 'Org2MSP.member')"
To deploy under a test environment or test KUBERNETES cluster (One chanincode by peer), I use the following connection.json:

{
    "address": "{{.peername}}.mycoolchaincode.cooldomain:9998",
    "dial_timeout": "10s",
    "tls_required": false
}

The variable {{.peername}} is related to the folllowing PEER environment variable:

    - CHAINCODE_AS_A_SERVICE_BUILDER_CONFIG={"peername":"peer0org2"}

NOTE: with this setup, each of the peers will have his own chaincode container. If you start all of the chaincode containers in debug mode (NODE_OPTIONS='--inspect=0.0.0.0:9229'), you will be able to remotely connect to the container using the IDE and debug using the port 9229. If you have a lot of peers and orgs, maybe the connected chaincode for debug will not be accessed by the transaction if the other peers endorse the transaction first. (Of Course, you can force the transaction to a specific peer configuring it on the client side).

So, I think that it is almost the same effort to setup a multi org environment setting the peer dev mode to true.

My best regards.


David




Em ter., 17 de mai. de 2022 às 06:14, satheesh via lists.hyperledger.org <ctsatheesh=yahoo.com@...> escreveu:

Hello Community,

Using Hyperledger fabric 2.4

While working on a Hyperledger Fabric use case,  realized that setting up a environment where peer can be run in
development mode (peer node start --peer-chaincodedev=true) is quite fast to iterate chaincode development.

Official documentation provides material to setup up such environment but for only one org.
But if we want to setup a multi-org consortium using peer development mode, Is there any reference material
available ? Appreciate any pointers.

Regards,
Satheesh




satheesh
 

Hello David,

Appreciate your inputs. Will attempt this and see if I can hop to next step

Regards,
Satheesh

On Tuesday, May 17, 2022, 11:47:35 PM GMT+5:30, David Faulstich Diniz Reis <davidfdr@...> wrote:


Hello Satheesh. How are you? I hope you are doing well.

My personal dev environment is using the CCAAS builders that came with 2.4+ version with vagrant and connecting remotely using an IDE (VSCODE or IntelliJ).

If you are using fabric samples, you just need change all of your peers to start with --peer-chaincodedev=true ( YAML line with command: peer node start --peer-chaincodedev=true - compose-test-net.yaml) and start your network to be able to debug.

In my case, when I am developing the chaincode, I start the chaincode using my IDE using the command:

-  "start:server-debug": "set -x && NODE_OPTIONS='--inspect=0.0.0.0:9229' fabric-chaincode-node server --chaincode-address=$CHAINCODE_SERVER_ADDRESS --chaincode-id=$CHAINCODE_ID",

  • The variable CHAINCODE_SERVER_ADDRESS is the same as "address" key of the connection.json (Ex.: mycoolchaincode.myserver.org:9998 and configure the /etc/hosts to resolve this dns when needed or use https://nip.io/ solution to get correct DNS resolution).
  • The variable CHAINCODE_ID may be obtained during install command;

The chaincode package that will be installed in all peers, I generate using the following commands (I am using Javascript / Typescript chaincodes):

  • tar cfz code.tar.gz connection.json ../META-INF
  • tar cfz mycoolchaincode.tgz metadata.json code.tar.gz
(I do the install  in all peers if needed);

NOTE: with this setup, all peers will use only one chaincode endpoint (running attached to IDE).

And finally, I change the endorsement rule to need only one endorsement and the peers execute only one time the chaincode. In a multi org, the breakpoint will get accessed a lot of times, turning the debug process a little more difficult:
  • --signature-policy "OR('Org1MSP.member', 'Org2MSP.member')"
To deploy under a test environment or test KUBERNETES cluster (One chanincode by peer), I use the following connection.json:

{
    "address": "{{.peername}}.mycoolchaincode.cooldomain:9998",
    "dial_timeout": "10s",
    "tls_required": false
}

The variable {{.peername}} is related to the folllowing PEER environment variable:

    - CHAINCODE_AS_A_SERVICE_BUILDER_CONFIG={"peername":"peer0org2"}

NOTE: with this setup, each of the peers will have his own chaincode container. If you start all of the chaincode containers in debug mode (NODE_OPTIONS='--inspect=0.0.0.0:9229'), you will be able to remotely connect to the container using the IDE and debug using the port 9229. If you have a lot of peers and orgs, maybe the connected chaincode for debug will not be accessed by the transaction if the other peers endorse the transaction first. (Of Course, you can force the transaction to a specific peer configuring it on the client side).

So, I think that it is almost the same effort to setup a multi org environment setting the peer dev mode to true.

My best regards.


David




Em ter., 17 de mai. de 2022 às 06:14, satheesh via lists.hyperledger.org <ctsatheesh=yahoo.com@...> escreveu:

Hello Community,

Using Hyperledger fabric 2.4

While working on a Hyperledger Fabric use case,  realized that setting up a environment where peer can be run in
development mode (peer node start --peer-chaincodedev=true) is quite fast to iterate chaincode development.

Official documentation provides material to setup up such environment but for only one org.
But if we want to setup a multi-org consortium using peer development mode, Is there any reference material
available ? Appreciate any pointers.

Regards,
Satheesh