티스토리 뷰

반응형

Private Data 저장 및 조회에 관련된 테스트 내용은 Hyperledger Fabric v1.2에서 Private Data 저장 및 조회 글을 참고하시기 바랍니다.


오류 발생

honeybee 네트워크에서 Private Data를 저장하기 위해 테스트하는 도중, invoke 명령에서 다음과 같은 오류가 발생하였습니다.

명령은 org1의 cli 컨테이너에서 org5의 peer0을 기준으로 실행하였습니다.

root@5a1435e84230:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_ADDRESS=peer0.org5.honeybee.com:7051 \
> CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.honeybee.com/users/Admin@org5.honeybee.com/msp \
> CORE_PEER_LOCALMSPID="org5MSP" \
> CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.honeybee.com/peers/peer0.org5.honeybee.com/tls/ca.crt \
> peer chaincode invoke -o orderer.org5.honeybee.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/honeybee.com/orderers/orderer.org5.honeybee.com/msp/tlscacerts/tlsca.honeybee.com-cert.pem -C honeybeechannel -n marblesp5 -c '{"Args":["initMarble","marble5","blue","35","tom","99"]}'
Error: endorsement failure during invoke. chaincode result: <nil>


총 6개의 org(org1 ~ org6) 중 org4번과 org6번에서만 해당 오류가 발생하였고, 나머지 org에서는 정상적으로 invoke 및 query가 가능하였습니다...


로그 확인

위와 같은 오류를 해결하기 위해, orderer 컨테이너와 peer0.org5 컨테이너의 로그를 확인해 보겠습니다.


orderer.org5.honeybee.com 컨테이너 로그 확인

2018-07-09 23:47:50.006 UTC [orderer/common/broadcast] Handle -> WARN 057 Error reading from <org1 호스트의 IP 주소>:41848: rpc error: code = Canceled desc = context canceled
===================================================================================


오류로 인해 명령이 정상적으로 수행되지 않았기 때문에 출력되는 로그인 것 같습니다.


peer0.org5.honeybee.com 컨테이너 로그 확인

다음으로 peer0.org5.honeybee.com 컨테이너의 로그를 확인해보니 다음과 같은 오류가 출력되었습니다.

2018-07-09 23:47:40.464 UTC [golang-platform] GenerateDockerBuild -> INFO 075 building chaincode with ldflagsOpt: '-ldflags "-linkmode external -extldflags '-static'"'
2018-07-09 23:47:40.464 UTC [golang-platform] GenerateDockerBuild -> INFO 076 building chaincode with tags: 
2018-07-09 23:47:49.996 UTC [chaincode-platform] func1 -> ERRO 077 Failed to generate platform-specific docker build: Error returned from build: 2 "# github.com/chaincode/marbles02_private/go
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:212:28: stub.GetPrivateData undefined (type shim.ChaincodeStubInterface has no field or method GetPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:232:12: stub.PutPrivateData undefined (type shim.ChaincodeStubInterface has no field or method PutPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:244:12: stub.PutPrivateData undefined (type shim.ChaincodeStubInterface has no field or method PutPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:262:6: stub.PutPrivateData undefined (type shim.ChaincodeStubInterface has no field or method PutPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:281:25: stub.GetPrivateData undefined (type shim.ChaincodeStubInterface has no field or method GetPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:305:25: stub.GetPrivateData undefined (type shim.ChaincodeStubInterface has no field or method GetPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:329:25: stub.GetPrivateData undefined (type shim.ChaincodeStubInterface has no field or method GetPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:344:12: stub.DelPrivateData undefined (type shim.ChaincodeStubInterface has no field or method DelPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:357:12: stub.DelPrivateData undefined (type shim.ChaincodeStubInterface has no field or method DelPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:363:12: stub.DelPrivateData undefined (type shim.ChaincodeStubInterface has no field or method DelPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:363:12: too many errors
"
2018-07-09 23:47:49.996 UTC [dockercontroller] deployImage -> ERRO 078 Error building images: Failed to generate platform-specific docker build: Error returned from build: 2 "# github.com/chaincode/marbles02_private/go
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:212:28: stub.GetPrivateData undefined (type shim.ChaincodeStubInterface has no field or method GetPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:232:12: stub.PutPrivateData undefined (type shim.ChaincodeStubInterface has no field or method PutPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:244:12: stub.PutPrivateData undefined (type shim.ChaincodeStubInterface has no field or method PutPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:262:6: stub.PutPrivateData undefined (type shim.ChaincodeStubInterface has no field or method PutPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:281:25: stub.GetPrivateData undefined (type shim.ChaincodeStubInterface has no field or method GetPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:305:25: stub.GetPrivateData undefined (type shim.ChaincodeStubInterface has no field or method GetPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:329:25: stub.GetPrivateData undefined (type shim.ChaincodeStubInterface has no field or method GetPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:344:12: stub.DelPrivateData undefined (type shim.ChaincodeStubInterface has no field or method DelPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:357:12: stub.DelPrivateData undefined (type shim.ChaincodeStubInterface has no field or method DelPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:363:12: stub.DelPrivateData undefined (type shim.ChaincodeStubInterface has no field or method DelPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:363:12: too many errors
"
2018-07-09 23:47:49.996 UTC [dockercontroller] deployImage -> ERRO 079 Image Output:
********************

********************
2018-07-09 23:47:50.000 UTC [chaincode] Launch -> ERRO 07a start failed: Failed to generate platform-specific docker build: Error returned from build: 2 "# github.com/chaincode/marbles02_private/go
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:212:28: stub.GetPrivateData undefined (type shim.ChaincodeStubInterface has no field or method GetPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:232:12: stub.PutPrivateData undefined (type shim.ChaincodeStubInterface has no field or method PutPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:244:12: stub.PutPrivateData undefined (type shim.ChaincodeStubInterface has no field or method PutPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:262:6: stub.PutPrivateData undefined (type shim.ChaincodeStubInterface has no field or method PutPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:281:25: stub.GetPrivateData undefined (type shim.ChaincodeStubInterface has no field or method GetPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:305:25: stub.GetPrivateData undefined (type shim.ChaincodeStubInterface has no field or method GetPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:329:25: stub.GetPrivateData undefined (type shim.ChaincodeStubInterface has no field or method GetPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:344:12: stub.DelPrivateData undefined (type shim.ChaincodeStubInterface has no field or method DelPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:357:12: stub.DelPrivateData undefined (type shim.ChaincodeStubInterface has no field or method DelPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:363:12: stub.DelPrivateData undefined (type shim.ChaincodeStubInterface has no field or method DelPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:363:12: too many errors
"
error starting container
error starting container
2018-07-09 23:47:50.000 UTC [endorser] SimulateProposal -> ERRO 07b [honeybeechannel][8f76d85e] failed to invoke chaincode name:"marblesp5" , error: Failed to generate platform-specific docker build: Error returned from build: 2 "# github.com/chaincode/marbles02_private/go
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:212:28: stub.GetPrivateData undefined (type shim.ChaincodeStubInterface has no field or method GetPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:232:12: stub.PutPrivateData undefined (type shim.ChaincodeStubInterface has no field or method PutPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:244:12: stub.PutPrivateData undefined (type shim.ChaincodeStubInterface has no field or method PutPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:262:6: stub.PutPrivateData undefined (type shim.ChaincodeStubInterface has no field or method PutPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:281:25: stub.GetPrivateData undefined (type shim.ChaincodeStubInterface has no field or method GetPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:305:25: stub.GetPrivateData undefined (type shim.ChaincodeStubInterface has no field or method GetPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:329:25: stub.GetPrivateData undefined (type shim.ChaincodeStubInterface has no field or method GetPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:344:12: stub.DelPrivateData undefined (type shim.ChaincodeStubInterface has no field or method DelPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:357:12: stub.DelPrivateData undefined (type shim.ChaincodeStubInterface has no field or method DelPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:363:12: stub.DelPrivateData undefined (type shim.ChaincodeStubInterface has no field or method DelPrivateData)
chaincode/input/src/github.com/chaincode/marbles02_private/go/marbles_chaincode_private.go:363:12: too many errors
"
error starting container
error starting container
failed to execute transaction 8f76d85e36bb58bc65e87182877d92b0df4f1b2c0a456ec081f3c901164e7821
github.com/hyperledger/fabric/core/chaincode.(*ChaincodeSupport).Execute
	/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:181
github.com/hyperledger/fabric/core/endorser.(*SupportImpl).Execute
	/opt/gopath/src/github.com/hyperledger/fabric/core/endorser/support.go:141
github.com/hyperledger/fabric/core/endorser.(*Endorser).callChaincode
	/opt/gopath/src/github.com/hyperledger/fabric/core/endorser/endorser.go:136
github.com/hyperledger/fabric/core/endorser.(*Endorser).SimulateProposal


오류 해결

peer0.org5.honeybee.com 컨테이너에서 출력된 로그를 검색해보니, hyperledger/fabric-ccenv 이미지가 없어서 발생한 오류였습니다.

실제로 각 호스트에서 docker image ls 명령을 통해 이미지를 확인해보니 org4와 org6의 호스트에서만 해당 버전에 맞는 hyperledger/fabric-ccenv 이미지가 존재하지 않았습니다.

따라서 org4와 org6에서 hyperledger/fabric-ccenv:1.2.0, hyperledger/fabric-ccenv:latest 이미지를 다운로드하고 네트워크를 다시 시작합니다. 기존에 hyperledger/fabric-ccenv:latest 이미지가 존재하고 있었다면, 버전이 안맞을 수도 있으니 해당 이미지를 제거하고 다시 다운로드합니다.

# 기존에 hyperledger/fabric-ccenv:latest 이미지가 있었던 경우, 해당 이미지 제거 후 재다운로드 필요
docker image rm hyperledger/fabric-ccenv:latest

docker image pull hyperledger/fabric-ccenv:1.2.0
docker image pull hyperledger/fabric-ccenv:latest

깔끔하게 모든 docker 이미지를 제거하고 다시 다운로드해도 됩니다.

docker image rm -f $(docker image ls -aq)

cd /opt/gopath/src/github.com/hyperledger
rm -rf fabric-samples
curl -sSL http://bit.ly/2ysbOFE | bash -s 1.2.0


네트워크를 다시 실행하면서 볼륨 데이터를 모두 지우기 때문에 기존에 조인했던 피어들이 모두 사라지게 됩니다. 따라서, peer0.org5, peer1.org5에 대한 조인 명령과 체인코드 install 명령을 다시 수행한 뒤 체인코드를 업그레이드하고 invoke 명령을 수행해주어야 합니다.

# peer0.org5를 honeybeechannel 채널에 조인
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.honeybee.com/users/Admin@org5.honeybee.com/msp CORE_PEER_ADDRESS=peer0.org5.honeybee.com:7051 CORE_PEER_LOCALMSPID="org5MSP" CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.honeybee.com/peers/peer0.org5.honeybee.com/tls/ca.crt peer channel join -b honeybeechannel.block 

# peer1.org5를 honeybeechannel 채널에 조인
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.honeybee.com/users/Admin@org5.honeybee.com/msp CORE_PEER_ADDRESS=peer1.org5.honeybee.com:7056 CORE_PEER_LOCALMSPID="org5MSP" CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.honeybee.com/peers/peer0.org5.honeybee.com/tls/ca.crt peer channel join -b honeybeechannel.block 

# 체인코드 2.0 버전 설치
peer chaincode install -n marblesp5 -v 2.0 -p github.com/chaincode/marbles02_private/go/

CORE_PEER_ADDRESS=peer1.org1.honeybee.com:7056 \
peer chaincode install -n marblesp5 -v 2.0 -p github.com/chaincode/marbles02_private/go/

CORE_PEER_ADDRESS=peer0.org5.honeybee.com:7051 \
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.honeybee.com/users/Admin@org5.honeybee.com/msp \
CORE_PEER_LOCALMSPID="org5MSP" \
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.honeybee.com/peers/peer0.org5.honeybee.com/tls/ca.crt \
peer chaincode install -n marblesp5 -v 2.0 -p github.com/chaincode/marbles02_private/go/

CORE_PEER_ADDRESS=peer1.org5.honeybee.com:7056 \
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.honeybee.com/users/Admin@org5.honeybee.com/msp \
CORE_PEER_LOCALMSPID="org5MSP" \
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.honeybee.com/peers/peer0.org5.honeybee.com/tls/ca.crt \
peer chaincode install -n marblesp5 -v 2.0 -p github.com/chaincode/marbles02_private/go/

# 체인코드 업그레이드
peer chaincode upgrade -o orderer.org1.honeybee.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/honeybee.com/orderers/orderer.org1.honeybee.com/msp/tlscacerts/tlsca.honeybee.com-cert.pem -C honeybeechannel -n marblesp5 -v 2.0 -c '{"Args":["init"]}' -P "OR('org1MSP.member','org5MSP.member')" --collections-config $GOPATH/src/github.com/chaincode/marbles02_private/collections_config5.json

# 체인코드 invoke 수행
CORE_PEER_ADDRESS=peer0.org5.honeybee.com:7051 \
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.honeybee.com/users/Admin@org5.honeybee.com/msp \
CORE_PEER_LOCALMSPID="org5MSP" \
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.honeybee.com/peers/peer0.org5.honeybee.com/tls/ca.crt \
peer chaincode invoke -o orderer.org5.honeybee.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/honeybee.com/orderers/orderer.org5.honeybee.com/msp/tlscacerts/tlsca.honeybee.com-cert.pem -C honeybeechannel -n marblesp5 -c '{"Args":["initMarble","marble5","blue","35","tom","99"]}'


invoke 명령이 정상적으로 수행 완료되면, query 명령을 실행해봅니다.

# 체인코드 query 수행
CORE_PEER_ADDRESS=peer0.org5.honeybee.com:7051 \
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.honeybee.com/users/Admin@org5.honeybee.com/msp \
CORE_PEER_LOCALMSPID="org5MSP" \
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.honeybee.com/peers/peer0.org5.honeybee.com/tls/ca.crt \
peer chaincode query -C honeybeechannel -n marblesp5 -c '{"Args":["readMarble","marble1"]}'

CORE_PEER_ADDRESS=peer0.org5.honeybee.com:7051 \
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.honeybee.com/users/Admin@org5.honeybee.com/msp \
CORE_PEER_LOCALMSPID="org5MSP" \
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.honeybee.com/peers/peer0.org5.honeybee.com/tls/ca.crt \
peer chaincode query -C honeybeechannel -n marblesp5 -c '{"Args":["readMarblePrivateDetails","marble5"]}'


query 명령도 정상적으로 수행 완료되는 것을 확인할 수 있습니다!

반응형
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함