【问题标题】:Transaction not found on remote peer在远程对等点上找不到事务
【发布时间】:2017-09-04 05:45:24
【问题描述】:

我正在尝试在 2 个实例上使用 Hyperledger Fabric v1.0 设置简单的区块链网络。

我的场景

实例 A:Orderer 和 Peer0
实例 B:Peer1

我基本上遵循了“Getting Started”页面的“使用本机二进制文件”部分。

我尝试的是在 instanceA 上启动 1 个订购者和 1 个对等方。 我安装、实例化、调用并查询了示例链代码。

然后我在实例 B 上启动了 1 个对等点。 我可以让 instanceB 上的 peer1 从 instanceA 加入我的频道。我可以从 instanceA 在 peer1 上安装链码。

但我无法从 instanceA 执行查询 peer1。 我至少可以看到在 instanceB 上安装了链码。

错误信息是:

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


以下是我尝试过的命令...

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

[InstanceA terminal2] 2. 启动orderer
$ CORE_PEER_LOCALMSPID=DEFAULT CORE_LOGGING_LEVEL=DEBUG ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 ORDERER_GENERAL_GENESISMETHOD=文件 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. 生成channel.tx
$ configtxgen -profile SampleSingleMSPSolo -outputCreateChannelTx channel.tx -channelID mychannel1

[InstanceA terminal3] 4. 启动 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. 创建通道
$ CORE_PEER_LOCALMSPID=DEFAULT peer channel create -o 127.0.0.1:7050 -c mychannel1 -f channel.tx

[InstanceA terminal1] 6. 将 peer0 加入 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. 安装链码
$ 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. 实例化链码
$ 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. 调用和查询命令
$ 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. 在instanceB上创建peer1
$ 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. 将实例 B 上的 peer1 从 instanceA 加入 mychannel1
$ CORE_PEER_LOCALMSPID=DEFAULT CORE_PEER_ADDRESS=instanceB:7051 对等通道加入-b mychannel1.block

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

[InstanceA terminal1] 11. 在实例 A 的实例 B 上的 peer1 上安装链代码
$ 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. 从instanceA查询peer1
$ CORE_PEER_ADDRESS=instanceB:7051 对等链码查询 -o 127.0.0.1:7050 -C mychannel1 -n mycc -c '{"Args":["query","a"]}'

我收到如下错误。但我至少可以看到 mycc 链码 instnceB 和 peer join 命令已成功完成。


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


我正在使用 2 个 ubuntu16.04 实例,根本没有使用 docker 或 vagrant。我通过 make native 编译了二进制文件。

instanceB 上的 Peer1 可能无法连接 instanceA 上的 orderer,因为我在 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

看起来 peer1 尝试连接 0.0.0.0 而不是 instanceA。

顺便说一句,我将组织名称从 SampleOrg 更改为 DEFAULT,因为否则我会遇到如下错误。

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.

我认为这可能是因为 instanceB 上的 peer1 未链接到 instanceA 上的 orderder,或者 peer0 进行的事务未完成并反映在 instanceB 上。但我不知道如何挖掘......

请帮帮我。
谢谢。

【问题讨论】:

    标签: hyperledger hyperledger-fabric


    【解决方案1】:

    我终于解决了我的问题。 原来我很简单。

    解决方案是将订购者的地址从 127.0.0.1:7050 更改为 (InstanceA 的 IP 地址):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
    

    通过这样做,instanceB 上的 Peer1 开始连接 instanceA 上的 orderer。

    看起来“CORE_PEER_COMMITTER_LEDGER_ORDERER 环境参数”和“-o 选项”不再使用或被 configtx.yaml 覆盖。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多