Re: Error while Commit Chaincode (External chaincode) #fabric-kubernetes #fabric-chaincode


Manish
 

The error seems to be quite self explanatory. Did you get the approvals from enough orgs (default is majority)? 


You can look at some helping commands in the docs - https://hyperledger-fabric.readthedocs.io/en/release-2.2/commands/peerlifecycle.html (particularly, checkcommitreadiness).


Thanks,

Manish


On Thu, Sep 9, 2021 at 10:59 AM <hiteshdutt05@...> wrote:

I am running a network with 

3 peer orgs with two peers each

1 orderer org with 3 orderers

 

PROBLEM FACED

While committing the chaincode getting an error 

txid [cd5f76fc81ae06b655516f3baab642f7cd580eb1ae07eb19fa91c0807ece846a] committed with status (ENDORSEMENT_POLICY_FAILURE) at peer1.4bfb93299d6f498d9346.centralindia.aksapp.io:443. Error: transaction invalidated with status (ENDORSEMENT_POLICY_FAILURE)

 

STEPS DONE FOR CHANNEL CREATION AND CHAINCODE INSTALL, APPROVE AND COMMIT

 

CREATE CHANNEL

 Setup Configtx.yaml file (file attached)

configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/dev-ind-tanla-al-ae.tx -channelID dev-ind-tanla-al-ae

peer channel create -o orderer1.2e127222c688446eb7c2.centralindia.aksapp.io:443 -c dev-ind-tanla-al-ae -f ./channel-artifacts/dev-ind-tanla-al-ae.tx --outputBlock ./channel-artifacts/dev-ind-demo-al-ae.block --tls --cafile /mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/orderer/ordererorg/orderer1.ordererorg/msp/tlscacerts/ca.crt

 

Set context for each peer of each org and join channel

JOIN CHANNEL

export CORE_PEER_LOCALMSPID='org1';export CORE_PEER_ADDRESS=peer1.8311494f2d6d47f585d5.centralindia.aksapp.io:443;export CORE_PEER_TLS_ROOTCERT_FILE=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org1/peer1.org1/msp/tlscacerts/ca.crt; export CORE_PEER_MSPCONFIGPATH=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org1/msp;

peer channel join -b ./channel-artifacts/dev-ind-demo-al-ae.block

 

export CORE_PEER_LOCALMSPID='org1';export CORE_PEER_ADDRESS=peer2.8311494f2d6d47f585d5.centralindia.aksapp.io:443;export CORE_PEER_TLS_ROOTCERT_FILE=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org1/peer2.org1/msp/tlscacerts/ca.crt; export CORE_PEER_MSPCONFIGPATH=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org1/msp;

peer channel join -b ./channel-artifacts/dev-ind-demo-al-ae.block

 

export CORE_PEER_LOCALMSPID='org2';export CORE_PEER_ADDRESS=peer1.4bfb93299d6f498d9346.centralindia.aksapp.io:443;export CORE_PEER_TLS_ROOTCERT_FILE=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org2/peer1.org2/msp/tlscacerts/ca.crt; export CORE_PEER_MSPCONFIGPATH=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org2/msp;

peer channel join -b ./channel-artifacts/dev-ind-demo-al-ae.block

 

export CORE_PEER_LOCALMSPID='org2';export CORE_PEER_ADDRESS=peer2.4bfb93299d6f498d9346.centralindia.aksapp.io:443;export CORE_PEER_TLS_ROOTCERT_FILE=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org2/peer2.org2/msp/tlscacerts/ca.crt; export CORE_PEER_MSPCONFIGPATH=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org2/msp;

peer channel join -b ./channel-artifacts/dev-ind-demo-al-ae.block

 

export CORE_PEER_LOCALMSPID='org3';export CORE_PEER_ADDRESS=peer1.0f2fb0c3ae804a12b351.centralindia.aksapp.io:443;export CORE_PEER_TLS_ROOTCERT_FILE=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org3/peer1.org3/msp/tlscacerts/ca.crt; export CORE_PEER_MSPCONFIGPATH=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org3/msp;

peer channel join -b ./channel-artifacts/dev-ind-demo-al-ae.block

 

export CORE_PEER_LOCALMSPID='org3';export CORE_PEER_ADDRESS=peer2.0f2fb0c3ae804a12b351.centralindia.aksapp.io:443;export CORE_PEER_TLS_ROOTCERT_FILE=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org3/peer2.org3/msp/tlscacerts/ca.crt; export CORE_PEER_MSPCONFIGPATH=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org3/msp;

peer channel join -b ./channel-artifacts/dev-ind-demo-al-ae.block

 

 

CHAINCODE PACKAGE INSTALL APPROVE AND COMMIT

 

PACKAGE

 

CHAINCODE LOCATION 

COMP_NAME=example

NAMESPACE=hlf1

chaincodeLocation=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/chaincode/

 

Create certificate and key

 

openssl req -nodes -x509 -newkey rsa:4096 -keyout crypto/key1.pem -out crypto/cert1.pem -subj "/C=IN/ST=TS/L=Hyderabad/O=example Inc/OU=Developer/CN=$COMP_NAME.$NAMESPACE/emailAddress=$SUPPORT_EMAIL"

 

Create package

 

Update connection.json [ set root_cert="" (with certificate created) address = "example.hlf1:9999" ]

 

create code.tar.gz

 

tar cfz code.tar.gz connection.json

tar cfz chaincode.tgz metadata.json code.tar.gz

 

package=$chaincodeLocation/chaincode.tgz

 

INSTALL 

export CORE_PEER_LOCALMSPID='org1';export CORE_PEER_ADDRESS=peer1.8311494f2d6d47f585d5.centralindia.aksapp.io:443;export CORE_PEER_TLS_ROOTCERT_FILE=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org1/peer1.org1/msp/tlscacerts/ca.crt; export CORE_PEER_MSPCONFIGPATH=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org1/msp;

peer lifecycle chaincode install $package #["copy package id, package id to be used during approve"]

 

export CORE_PEER_LOCALMSPID='org1';export CORE_PEER_ADDRESS=peer2.8311494f2d6d47f585d5.centralindia.aksapp.io:443;export CORE_PEER_TLS_ROOTCERT_FILE=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org1/peer2.org1/msp/tlscacerts/ca.crt; export CORE_PEER_MSPCONFIGPATH=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org1/msp;

peer lifecycle chaincode install $package #["copy package id, package id to be used during approve, packageId is same as packageId from other peer"]

 

export CORE_PEER_LOCALMSPID='org2';export CORE_PEER_ADDRESS=peer1.4bfb93299d6f498d9346.centralindia.aksapp.io:443;export CORE_PEER_TLS_ROOTCERT_FILE=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org2/peer1.org2/msp/tlscacerts/ca.crt; export CORE_PEER_MSPCONFIGPATH=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org2/msp;

peer lifecycle chaincode install $package #["copy package id, package id to be used during approve, packageId is same as packageId from other peer"]

 

export CORE_PEER_LOCALMSPID='org2';export CORE_PEER_ADDRESS=peer2.4bfb93299d6f498d9346.centralindia.aksapp.io:443;export CORE_PEER_TLS_ROOTCERT_FILE=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org2/peer2.org2/msp/tlscacerts/ca.crt; export CORE_PEER_MSPCONFIGPATH=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org2/msp;

peer lifecycle chaincode install $package #["copy package id, package id to be used during approve, packageId is same as packageId from other peer"]

 

export CORE_PEER_LOCALMSPID='org3';export CORE_PEER_ADDRESS=peer1.0f2fb0c3ae804a12b351.centralindia.aksapp.io:443;export CORE_PEER_TLS_ROOTCERT_FILE=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org3/peer1.org3/msp/tlscacerts/ca.crt; export CORE_PEER_MSPCONFIGPATH=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org3/msp;

peer lifecycle chaincode install $package #["copy package id, package id to be used during approve, packageId is same as packageId from other peer"]

 

export CORE_PEER_LOCALMSPID='org3';export CORE_PEER_ADDRESS=peer2.0f2fb0c3ae804a12b351.centralindia.aksapp.io:443;export CORE_PEER_TLS_ROOTCERT_FILE=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org3/peer2.org3/msp/tlscacerts/ca.crt; export CORE_PEER_MSPCONFIGPATH=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org3/msp;

peer lifecycle chaincode install $package #["copy package id, package id to be used during approve, packageId is same as packageId from other peer"]

 

APPROVE

export CORE_PEER_LOCALMSPID='org1';export CORE_PEER_ADDRESS=peer1.8311494f2d6d47f585d5.centralindia.aksapp.io:443;export CORE_PEER_TLS_ROOTCERT_FILE=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org1/peer1.org1/msp/tlscacerts/ca.crt; export CORE_PEER_MSPCONFIGPATH=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org1/msp;

peer lifecycle chaincode approveformyorg -n $chaincodeName -C $channelName -o orderer1.2e127222c688446eb7c2.centralindia.aksapp.io:443 --tls --cafile /mnt/c/workspace/git/Tanla/hlf-artifacts/installpeer/cryptoconfig/orderer/ordererorg/orderer1.ordererorg/msp/tlscacerts/ca.crt --package-id demo_2.0:02904171931c11dc8f36d20d97ca5bc4650aa66ffade9dc303b6100ddd790083 --version v1 --sequence 1 #["package id is used from package id generated during install"]

 

export CORE_PEER_LOCALMSPID='org2';export CORE_PEER_ADDRESS=peer1.4bfb93299d6f498d9346.centralindia.aksapp.io:443;export CORE_PEER_TLS_ROOTCERT_FILE=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org2/peer1.org2/msp/tlscacerts/ca.crt; export CORE_PEER_MSPCONFIGPATH=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org2/msp;

peer lifecycle chaincode approveformyorg -n $chaincodeName -C $channelName -o orderer1.2e127222c688446eb7c2.centralindia.aksapp.io:443 --tls --cafile /mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/orderer/ordererorg/orderer1.ordererorg/msp/tlscacerts/ca.crt --package-id demo_2.0:02904171931c11dc8f36d20d97ca5bc4650aa66ffade9dc303b6100ddd790083 --version v1 --sequence 1 #["package id is used from package id generated during install"]

 

export CORE_PEER_LOCALMSPID='org3';export CORE_PEER_ADDRESS=peer1.0f2fb0c3ae804a12b351.centralindia.aksapp.io:443;export CORE_PEER_TLS_ROOTCERT_FILE=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org3/peer1.org3/msp/tlscacerts/ca.crt; export CORE_PEER_MSPCONFIGPATH=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org3/msp;

peer lifecycle chaincode approveformyorg -n $chaincodeName -C $channelName -o orderer1.2e127222c688446eb7c2.centralindia.aksapp.io:443 --tls --cafile /mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/orderer/ordererorg/orderer1.ordererorg/msp/tlscacerts/ca.crt --package-id demo_2.0:02904171931c11dc8f36d20d97ca5bc4650aa66ffade9dc303b6100ddd790083 --version v1 --sequence 1 #["package id is used from package id generated during install"]

 

COMMIT

export CORE_PEER_LOCALMSPID='org2';export CORE_PEER_ADDRESS=peer2.4bfb93299d6f498d9346.centralindia.aksapp.io:443;export CORE_PEER_TLS_ROOTCERT_FILE=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org2/peer2.org2/msp/tlscacerts/ca.crt; export CORE_PEER_MSPCONFIGPATH=/mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/peer/org2/msp;

peer lifecycle chaincode commit -o orderer1.2e127222c688446eb7c2.centralindia.aksapp.io:443 --tls --cafile /mnt/c/workspace/git/demo/hlf-artifacts/installpeer/cryptoconfig/orderer/ordererorg/orderer1.ordererorg/msp/tlscacerts/ca.crt -C dev-ind-demo-al-ae -n $chaincodeName --version v1 --sequence 1



PS: IF I USE CONFIGTX.YAML WITH SINGLE PEER ORG (with two peers) AND CREATE A CHANNEL, I AM ABLE TO USE COMMIT CHAINCODE FOR SINGLE ORG ON CHANNEL SCENARIO

Join fabric@lists.hyperledger.org to automatically receive all group messages.