Transaction not found on remote peer

僤鯓⒐⒋嵵緔 提交于 2020-01-14 03:45:06

问题


I'm trying to setup simple blockchain network with Hyperledger fabric v1.0 on 2 instances.

My scenario

Instance A: Orderer and Peer0
Instance B: Peer1

I basically followed the "Use the native binaries" section of "Getting Started" page.

What I tried is I started 1 orderer and 1 peer on instanceA. I installed, instantiated, invoked and made a query the example chaincode.

Then I started 1 peer on instanceB. I could let peer1 on instanceB join my channel from instanceA. I could install the chaincode on peer1 from instanceA.

But I could not execute query peer1 from instanceA. I can see at least chaincode installed on instanceB.

Error message is:

Error: Error endorsing query: rpc error: code = 2 desc = failed to obtain cds for mycc - transaction not found mycc/mychannel1


Below are commands I tried...

[InstanceA terminal1] 1. generate orderer.block
$ configtxgen -profile SampleSingleMSPSolo -outputBlock orderer.block

[InstanceA terminal2] 2. start orderer
$ CORE_PEER_LOCALMSPID=DEFAULT CORE_LOGGING_LEVEL=DEBUG ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 ORDERER_GENERAL_GENESISMETHOD=file ORDERER_GENERAL_GENESISFILE=./orderer.block

2017-04-08 23:38:41.562 UTC [orderer/multichain] NewManagerImpl -> INFO 001 Starting with system channel testchainid and orderer type solo
2017-04-08 23:38:41.562 UTC [orderer/main] NewServer -> INFO 002 Starting orderer
2017-04-08 23:38:41.562 UTC [orderer/main] main -> INFO 003 Beginning to serve requests
2017-04-08 23:39:39.881 UTC [orderer/multichain] newChain -> INFO 004 Created and starting new chain mychannel1


[InstanceA terminal1] 3. generate channel.tx
$ configtxgen -profile SampleSingleMSPSolo -outputCreateChannelTx channel.tx -channelID mychannel1

[InstanceA terminal3] 4. start peer0
$ CORE_PEER_GOSSIP_EXTERNALENDPOINT=127.0.0.1:7051 CORE_LOGGING_LEVEL=DEBUG CORE_PEER_LOCALMSPID=DEFAULT peer node start --peer-defaultchain=false

[InstanceA terminal1] 5. Create Channel
$ CORE_PEER_LOCALMSPID=DEFAULT peer channel create -o 127.0.0.1:7050 -c mychannel1 -f channel.tx

[InstanceA terminal1] 6. Join peer0 to mychannel1
$ CORE_PEER_LOCALMSPID=DEFAULT peer channel join -b mychannel1.block

Peer joined the channel!
2017-04-08 23:39:54.463 UTC [main] main -> INFO 001 Exiting.....

[InstanceA terminal1] 7. Install a chaincode
$ CORE_PEER_LOCALMSPID=DEFAULT peer chaincode install -o 127.0.0.1:7050 -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02

ncode/go/chaincode_example02
2017-04-08 23:40:05.744 UTC [golang-platform] writeGopathSrc -> INFO 001 rootDirectory = /home/kouohhashi/work/src
2017-04-08 23:40:05.744 UTC [container] WriteFolderToTarPackage -> INFO 002 rootDirectory = /home/kouohhashi/work/src
2017-04-08 23:40:36.242 UTC [main] main -> INFO 003 Exiting.....

[InstanceA terminal1] 7. Instantiate the chaincode
$ CORE_PEER_ADDRESS=127.0.0.1:7051 CORE_PEER_LOCALMSPID=DEFAULT peer chaincode instantiate -o 127.0.0.1:7050 -C mychannel1 -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Args":["init","a", "100", "b","200"]}'

 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Args":["init","a", "100", "b","200"]}'
2017-04-08 23:40:39.892 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2017-04-08 23:40:39.893 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2017-04-08 23:40:42.194 UTC [main] main -> INFO 003 Exiting.....

[InstanceA terminal1] 8. Invoke and query a command
$ CORE_PEER_ADDRESS=127.0.0.1:7051 peer chaincode invoke -o 127.0.0.1:7050 -C mychannel1 -n mycc -c '{"Args":["invoke","a","b","10"]}' $ CORE_PEER_ADDRESS=127.0.0.1:7051 peer chaincode query -o 127.0.0.1:7050 -C mychannel1 -n mycc -c '{"Args":["query","a"]}'

Query Result: 90
2017-04-08 23:40:51.664 UTC [main] main -> INFO 001 Exiting.....

[InstanceB terminal1] 9. Create peer1 on instanceB
$ CORE_PEER_MSPCONFIGPATH=/home/kouohhashi/work/src/github.com/hyperledger/fabric/msp/sampleconfig CORE_PEER_GOSSIP_EXTERNALENDPOINT=instanceB:7051 CORE_LOGGING_LEVEL=DEBUG CORE_PEER_LOCALMSPID=DEFAULT peer node start --peer-defaultchain=false

[InstanceA terminal1] 10. Join peer1 on instance B to mychannel1 from instanceA
$ CORE_PEER_LOCALMSPID=DEFAULT CORE_PEER_ADDRESS=instanceB:7051 peer channel join -b mychannel1.block

Peer joined the channel!
2017-04-08 23:42:14.799 UTC [main] main -> INFO 001 Exiting.....

[InstanceA terminal1] 11. Install chaincode on peer1 on instanceB from instance A
$ CORE_PEER_LOCALMSPID=DEFAULT CORE_PEER_ADDRESS=instanceB:7051 peer chaincode install -o 127.0.0.1:7050 -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02

2017-04-08 23:42:23.166 UTC [golang-platform] writeGopathSrc -> INFO 001 rootDirectory = /home/kouohhashi/work/src
2017-04-08 23:42:23.166 UTC [container] WriteFolderToTarPackage -> INFO 002 rootDirectory = /home/kouohhashi/work/src
2017-04-08 23:42:39.191 UTC [main] main -> INFO 003 Exiting.....

[InstanceA terminal1] 12. Query peer1 from instanceA
$ CORE_PEER_ADDRESS=instanceB:7051 peer chaincode query -o 127.0.0.1:7050 -C mychannel1 -n mycc -c '{"Args":["query","a"]}'

I got errors like below. But I can see at least mycc chaincode on instnceB and peer join command was completed successfully.


Error: Error endorsing query: rpc error: code = 2 desc = failed to obtain cds for mycc - transaction not found mycc/mychannel1


I'm using 2 ubuntu16.04 instances and not using docker or vagrant at all. I compiled binaries by make native.

Peer1 on instanceB may not connect orderer on instanceA because I saw the error log on peer1.

2017-04-08 23:42:14.903 UTC [deliveryClient] NewDeliverService -> ERRO 286 Cannot dial to 0.0.0.0:7050, because of grpc: timed out when dialing

Looks like peer1 tried to connect 0.0.0.0 instead of instanceA.

By the way I changed the Name of Organizations to DEFAULT from SampleOrg because I got errors like below otherwise.

2017-04-08 05:17:57.919 UTC [gossip/service] configUpdated -> ERRO 25e Tried joining channel mychannel1 but our org( DEFAULT ), isn't among the orgs of the channel: [SampleOrg] , aborting.

I think this may be because peer1 on instanceB was not linked to orderder on instanceA or transaction made by peer0 was not completed and reflected on instanceB. But I have no idea how to dig in...

Please give me help.
Thanks.


回答1:


I finally solved my problem. I turned out to be simple.

The solution was changing addresses of the orderer from 127.0.0.1:7050 to (IP Address of InstanceA):7050

common/configtx/tool/configtx.yaml

Orderer: &OrdererDefaults

    # Orderer Type: The orderer implementation to start.
    # Available types are "solo" and "kafka".
    OrdererType: solo

    Addresses:
        # - 127.0.0.1:7050
        - <IP Address of InstanceA>:7050

By doing this, Peer1 on instanceB start connecting orderer on instanceA.

It looks like "CORE_PEER_COMMITTER_LEDGER_ORDERER environmental parameter" and "-o option" were not used anymore or overwritten by configtx.yaml.



来源:https://stackoverflow.com/questions/43301866/transaction-not-found-on-remote-peer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!