第一个网络示例:调用期间认可失败

时间:2018-09-26 16:14:45

标签: hyperledger-fabric

我正在按照手动步骤从此处建立Hyperledger Fabric网络:https://hyperledger-fabric.readthedocs.io/en/release-1.2/build_network.html#run-the-tools

我已按照教程建立了网络:

# Create certificates
cryptogen generate --config=./crypto-config.yaml

# Create genesis block
configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block

# The channel.tx artifact contains the definitions for our sample channel
export CHANNEL_NAME=mychannel  && ../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME

# Define anchor peers
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP

我使用1.2.0版本的二进制文件登录到CLI容器:

root@6207ffb7b4d2:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer version
peer:
 Version: 1.2.0
 Commit SHA: cae2ad4
 Go version: go1.10
 OS/Arch: linux/amd64
 Experimental features: false
 Chaincode:
  Base Image Version: 0.4.10
  Base Docker Namespace: hyperledger
  Base Docker Label: org.hyperledger.fabric
  Docker Namespace: hyperledger

该频道也已创建,并在本教程之后添加了同行:

# Inside the CLI container, create the channel referencing the channel transaction and orderer root certificate
export CHANNEL_NAME=mychannel
export ORDERER_ROOT_CERT=`pwd`/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls --cafile $ORDERER_ROOT_CERT

# Join peer0.org1.example.com to the channel ($CHANNEL_NAME.block)
export CORE_PEER_MSPCONFIGPATH=`pwd`/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp 
export CORE_PEER_ADDRESS=peer0.org1.example.com:7051
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=`pwd`/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt 

peer channel join -b mychannel.block

# Update the network to mark peer0.org1.example.com as the anchor peer for Org1
peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org1MSPanchors.tx --tls --cafile $ORDERER_ROOT_CERT

# Join peer0.org2.example.com to the channel and update the network to add it as the anchor peer for Org2
export CORE_PEER_MSPCONFIGPATH=`pwd`/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp 
export CORE_PEER_ADDRESS=peer0.org2.example.com:7051
export CORE_PEER_LOCALMSPID="Org2MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=`pwd`/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt 

peer channel join -b mychannel.block
peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org2MSPanchors.tx --tls --cafile $ORDERER_ROOT_CERT

可以实例化并查询示例node.js链码:

# This installs the Node.js chaincode, make note of the -l flag; we use this to specify the language
peer chaincode install -n mycc -v 1.0 -l node -p /opt/gopath/src/github.com/chaincode/chaincode_example02/node/

# This instantiates the Node.js chaincode as installed above. Note the arguments passed as a JSON string after -c
# and the endorsement conditions after -P stating an endorsement from Org1MSP.peer AND Org2MSP.peer.
peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile $ORDERER_ROOT_CERT -C $CHANNEL_NAME -n mycc -l node -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')"

# Query the mycc chaincode with a "query":"a" argument.
peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}'

证书在以下位置:

root@6207ffb7b4d2:/opt/gopath/src/github.com/hyperledger/fabric/peer# echo $PEER0_ORG1_CERT
/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
root@6207ffb7b4d2:/opt/gopath/src/github.com/hyperledger/fabric/peer# cat $PEER0_ORG1_CERT
-----BEGIN CERTIFICATE-----
MIICSjCCAfCgAwIBAgIRAKdICjqStOQOGapyt/MHpPUwCgYIKoZIzj0EAwIwdjEL
MAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG
cmFuY2lzY28xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHzAdBgNVBAMTFnRs
c2NhLm9yZzEuZXhhbXBsZS5jb20wHhcNMTgwOTI2MTU1MjI4WhcNMjgwOTIzMTU1
MjI4WjB2MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UE
BxMNU2FuIEZyYW5jaXNjbzEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEfMB0G
A1UEAxMWdGxzY2Eub3JnMS5leGFtcGxlLmNvbTBZMBMGByqGSM49AgEGCCqGSM49
AwEHA0IABMekA2fie0Ol3SlqA2I6GD0ar3njl8thzHjHauuo871RlnYR6p9v6MLy
6/XXR5wjSjCBTO34Hn8iBJ7QYRT8/oCjXzBdMA4GA1UdDwEB/wQEAwIBpjAPBgNV
HSUECDAGBgRVHSUAMA8GA1UdEwEB/wQFMAMBAf8wKQYDVR0OBCIEICB+G5VMJDdn
EYTewMHTlhZKYXISUWehzXZaFmhYAax0MAoGCCqGSM49BAMCA0gAMEUCIQD30d8N
ApJCVRr3xO/9CdaTtyivz9f+um4lNJwNMwFnpwIgaLxnnV1mrXNWAtcyCrg3C2my
1oHseq7p4ZQ2kFF3PGQ=
-----END CERTIFICATE-----
root@6207ffb7b4d2:/opt/gopath/src/github.com/hyperledger/fabric/peer# cat $PEER0_ORG2_CERT
-----BEGIN CERTIFICATE-----
MIICSTCCAfCgAwIBAgIRANZbXA5/5fhshKuA/u6wX24wCgYIKoZIzj0EAwIwdjEL
MAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG
cmFuY2lzY28xGTAXBgNVBAoTEG9yZzIuZXhhbXBsZS5jb20xHzAdBgNVBAMTFnRs
c2NhLm9yZzIuZXhhbXBsZS5jb20wHhcNMTgwOTI2MTU1MjI4WhcNMjgwOTIzMTU1
MjI4WjB2MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UE
BxMNU2FuIEZyYW5jaXNjbzEZMBcGA1UEChMQb3JnMi5leGFtcGxlLmNvbTEfMB0G
A1UEAxMWdGxzY2Eub3JnMi5leGFtcGxlLmNvbTBZMBMGByqGSM49AgEGCCqGSM49
AwEHA0IABPTTJbjJVY9+dZZtFhhsdW02/fUx4Hb7Qqaq36KBHq66An79eP0qFuAQ
cjmropd6VsTwN8csuHcVcrb0F8GKorujXzBdMA4GA1UdDwEB/wQEAwIBpjAPBgNV
HSUECDAGBgRVHSUAMA8GA1UdEwEB/wQFMAMBAf8wKQYDVR0OBCIEIDEaDZGFwbOe
dDANWQiSE2guFEO2uLydN3FJGS3eAQHbMAoGCCqGSM49BAMCA0cAMEQCIHy5+yHU
I0EsTdQXZu2HCYHuJbvYBjEb9eekQYM287BHAiB8YYl2jFF+DK9Fx8sfTVCsP8MR
zrNfBMn0Kpa9WnW89g==
-----END CERTIFICATE-----

现在出现错误:链代码调用失败,并显示了关于背书失败的描述性消息。

root@6207ffb7b4d2:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode invoke -o orderer.example.com:7050 --tls true --cafile $ORDERER_ROOT_CERT -C $CHANNEL_NAME -n mycc \
>     --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles $PEER0_ORG1_CERT \
>     --peerAddresses peer0.org2.example.com:7051 --tlsRootCertFiles $PEER0_ORG2_CERT \
>     -c '{"Args":["invoke","a","b","10"]}'
Error: endorsement failure during invoke. chaincode result: <nil>

关于可能出了什么问题的任何想法?

1 个答案:

答案 0 :(得分:0)

您可以在加入cli容器之前尝试使用该命令:

t

例如:CHANNEL_NAME=$CHANNEL_NAME TIMEOUT=(pick_a_value) docker-compose -f docker-compose-cli.yaml up -d

我希望它能对您有所帮助。

相关问题