I have a hyperledger fabric testnet with 2 orgs, 3 peers in org1 and 2 peers in org2. The peer0 of each organization is the anchor peer. I want to instantiate a chaincode with an endorsment policy with only one organization: Org1, so I specify the policy: "AND('org1MSP.member')".
I've installed the chaincode in the peers of the org1 only, because org2 is not endorser. However, the chaincode doesn't instantiate because it sending the proposal to the peers that are in the other organization (org2).
The problem is because these peers in the org2 don't have the chaincode installed, but...why the SDK is sending the endorsement request to the peers that not belongs to the endorsement policy?
Here's is my config file, as you can see I only have one peer of the org1: https://gist.github.com/mtnieto/02dd17097de64a73bd627594056598ed
I have add to the config the following features, but it's not working.
channels:
# multi-org test channel
examplechannel:
peers:
peer0.org1.example.com:
endorsingPeer: true
chaincodeQuery: true
ledgerQuery: true
eventSource: true
peer1.org1.example.com:
endorsingPeer: false
chaincodeQuery: false
ledgerQuery: true
eventSource: true
peer2.org1.example.com:
endorsingPeer: false
chaincodeQuery: false
ledgerQuery: true
eventSource: true
peer0.org2.example.com:
endorsingPeer: false
chaincodeQuery: false
ledgerQuery: true
eventSource: true
peer1.org2.example.com:
endorsingPeer: false
chaincodeQuery: false
ledgerQuery: true
eventSource: true
The logs are the following:
"error": "Error creating Chaincode: sending deploy transaction proposal failed: Multiple errors occurred: - Transaction processing for endorser [peer0.org2.example.com:8051]: Endorser Client Status Code: (23) CHAINCODE_NAME_NOT_FOUND. Description: cannot get package for chaincode (examplecc:2) - Transaction processing for endorser [peer1.org2.example.com:6051]: Endorser Client Status Code: (23) CHAINCODE_NAME_NOT_FOUND. Description: cannot get package for chaincode (examplecc:2)"
The code to instantiate the chaincode is the following. (In a previously phase I have already installed the chaincode)
sdk, err = fabsdk.New(config.FromFile("config.yaml"))
if err != nil {
log.Errorf("Failed to create new SDK: ", err)
return nil, err
}
adminContext := sdk.Context("admin", "org1"))
// Org resource management client
orgResMgmt, err := resmgmt.New(adminContext)
if err != nil {
log.Errorf("Failed to create resource management client %v: ", err)
return nil, err
}
ccPolicy, err := cauthdsl.FromString(instantiateReq.EndorsmentPolicy)
if err != nil {
log.Errorf(" Error parsing endorsment policy %v: ", err)
return "", err
}
instantiateRequest := resmgmt.InstantiateCCRequest{Name: instantiateReq.Name, Path: instantiateReq.Path, Version: instantiateReq.Version, Args: instantiateReq.Args, Policy: ccPolicy}
This happens when the peer is updated to be anchor. In other words, If I don't execute the following commands in the peers when I init the network, the error is not happening.
(in peer0 org1 context)
peer channel update -o orderer0.example.com:7050 -c $CHANNEL_NAME --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -f ./channel-artifacts/org1MSPanchors.tx >&log.txt
in peer0 org2 context
peer channel update -o orderer0.example.com:7050 -c $CHANNEL_NAME --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -f ./channel-artifacts/org2MSPanchors.tx >&log.txt
It's a bug in the 1.4.1 version, the not endorser organization is trying to execute lscc and to endorse the transaction.
I have upgrade the network to 1.4.2 and now it seems that the issue has disappeared.