3

I have used BYFN to create a fabric network, with configuration

2 ORG with each ORG having 2 peers (each having their own couch-db as state db), 1 orderer and 2 fabric-ca.

Now, I installed a chaincode(named as ordering-network) on peer0.org1 and peer0.org2 and started the chaincode on peer0.org1.

Scenario:

  1. I am able to submit transactions on the chaincode using org1 admin credentials or by creating participant identity all linked to org1.
  2. I was not able to start chaincode on peer0.org2 with below exception.

    Error: Error trying to start business network. Error: No valid responses from any peers.Response from attempted peer comms was an error: Error: 2 UNKNOWN: chaincode error (status: 500, message: chaincode exists ordering-network)

  3. I tried to access the chaincode with admin credentials of org2 through composer-playground, but was returned with an exception

    Error: Error trying to ping. Error: 2 UNKNOWN: error executing chaincode: transaction returned with failure: Error: The current identity, with the name 'admin' and the identifier '50a2c29340d9011a6530a95ead8ad83effc7804880ce482f8926aabaf6f1bb87', has not been registered

Questions:

  1. If a single chaincode is installed on multiple peers is it only required to be started (instantiated) by any one of the peers (across orgs)?
  2. If I want both the peers to be able to modify the chaincode, what will be process? By process, I mean each of the org's peer will need to modify and update the code at their end or any one org's member can update the chaincode and it will be instantiated on all peers?
  3. Is endorsement policy responsible to make sure the involvement of multiple peers of different org in a chaincode?

Apologies for the long post, but I'm not able to understand how single chaincode work across multiple organisations.

Source to ChainCode: https://github.com/monarch0111/ordering-network/

Abhishek
  • 63
  • 6

2 Answers2

3
  1. A chaincode needs to be instantiated on a channel only once. In other words, you only need to execute the peer chaincode instantiate ...... command on one of the peers in a channel. If you issue the command again after the chaincode is instantiated on the channel, you will probably get an error like what you mentioned in Scenario 2.

  2. If you want to modify the existing chaincode, which we also call it upgrading the chaincode (keeping the same chaincode name while changing the version number) . You will have to install it on those peers which you want them to be the endorsers, such that they can undergo transaction simulation during the execution phase. However, you only need to call peer chaincode upgrade ...... once only, just like the case when instantiating the chaincode. Doing so is just like making a broadcast and telling every member of the channel that the chaincode has been upgraded to a newer version.

    To further reiterate the point, it is not required that every peer in a channel to install the chaincode. Only a subset of the peers have to do so and we call them the endorsing peers.

  3. An endorsement policy defines which peers/ how many peers should execute the transaction (transaction simulation) and agree on the same executed result on a transaction. Let's say you have three organizations in a channel, you could specify the endorsement policy as AND('Org1.member', 'Org2.member') or AND('Org1.member', 'Org2.member','Org3.member') which depends on your need. But to say, defining multiple peers from different organizations in the endorsement policy helps to ensure that the execution results are deterministic.

    You could reference the docs here for more information. https://hyperledger-fabric.readthedocs.io/en/release-1.2/endorsement-policies.html

    Also, I suggest you to have a look on the answer from here to understand the intuition behind. Hyperledger Blockchain Endorsement Policy Guidelines/Recommendation

Isaac Wong
  • 288
  • 3
  • 10
0

1 - No is not required. Once the chaincode has been installed in each peer, the instantiation of the network must be executed only one time.

2 - Here a high-level overview of the workflow:

  • a - The client application submits a request to the chaincodes installed on the peers.
  • b - The chaincode of each peer endorses the transaction, according with the endorsement policy.
  • c - If the transaction collects enough endorsement can be committed and the chaincode modifies the state of the database ( change the value of the asset) and the ledger.

Here the official documentation.

3 - Yes, the endorsement policy defines which peers have to endorse the transaction to be considered valid.

Leonardo Carraro
  • 1,532
  • 1
  • 11
  • 24