区块链

0-Fabric错误集锦

2018-10-09  本文已影响699人  cystone

记录开发过程中遇到的各种错误和解决办法

  1. 创建通道的时候遇到的错误:

    Error: got unexpected status: FORBIDDEN -- Failed to reach implicit threshold of 1 sub-policies, required 1 remaining: permission denied
    

    Peer加入通道时遇到的错误,此时Peer可以安装链码,但是不能实例化:

    2018-10-09 10:20:14.228 CST [blocksProvider] DeliverBlocks -> ERRO 386 [fabricchannel] Got error &{FORBIDDEN}
    
    2018-10-09 10:53:06.071 CST [common/deliver] deliverBlocks -> WARN 013 [channel: fabricchannel] Client authorization revoked for deliver request from 127.0.0.1:48986: Failed to reach implicit threshold of 1 sub-policies, required 1 remaining: permission denied
    

    我的解决办法:

    按照以上思路解决再三检查配置文件之后,仍未解决,最终将crypto-config.yaml中的PeerOrgs->EnableNodeOUs设为true,然后问题解决。目前还不能非常肯定问题的原因,但是感觉还是和账户管理相关。

    其他可能的解决思路:

    • 检查配置文件中各种MSPID的对应是否一致,比如core.yaml中的“localMspId”和orderer.yaml中的“LocalMSPID”必须和configtx.yaml中的ID一致。
    • 检查各种证书路径是否正确。如果设置了环境变量也要检查。
    • 检查configtx.yaml中“Organizations”下组织的权限规则设置是否有问题。
    • 每次修改完成配置文件之后,删除core.yaml,orderer.yaml,configtx.yaml,crypto-config.yaml以外的所有文件,以防残余文件产生冲突。
  2. 启动orderer start的时候报错:

    panic: Error creating channelconfig bundle: initializing configtx manager failed: bad channel ID: channel ID 'Ordererchannel' contains illegal characters
    

    创建orderer创世块的时候,-channelID 后边接的通道名不能包含大写。该处通道名,不能和peer channel create 创建的通道名一样,不然也会出现 1 中的错误 got unexpected status: FORBIDDEN

    $ configtxgen -profile OrdererChannel -outputBlock genesisblock -channelID ordererchannel
    
  3. 多Peer节点操作链码时报错“chaincode fingerprint mismatch: data mismatch”

    Error: endorsement failure during query. response: status:500 message:"failed to execute transaction bed01c78367286e45aafef9e85764993b5315a63f686974c7c70055512365118: [channel atlchannel] failed to get chaincode container info for cc:1.0: could not get chaincode code: chaincode fingerprint mismatch: data mismatch"
    

    解决方案,先打包链码再在各个peer安装链码安装包:

    $ peer chaincode package -n cc -p github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd -v 1.02 ccpack.out  // 打包链码安装包
    
    $ peer chaincode install ccpack.out // 安装链码。注意:这里不需要-n -v -p 的参数,生成package的时候已经指定这些参数了。
    
    $ peer chaincode update -o 148.70.109.243:7050 -C atlchannel -n cc -v 1.02 -c '{"Args":["init","a","100","b","200"]}'   // (可选)升级链码
    
  4. 执行"peer chaincode query"无反应。
    问题背景:搭建两个Peer节点,第一个Peer安装完Chaincode测试没有问题,第二个Peer安装完Chaincode之后,执行"peer chaincode query" 等了很久没有反应。

    解决方案:什么也没做,去吃了个饭,回来居然没问题了,可以查询出结果。据说使用SDK查询的时候,如果没有同步完成会有返回信息,但是CLI没有。

    问题反思:query查询的是本地的内容,应该和网络没什么关系,一致查不出结果,很可能是peer的账本文件没有同步完成导致的。以后再遇到此类问题应该注意的地方:

    • configtx.yaml->Organizations->SampleOrg->AnchorPeers 这个值应该要设置,Anchor Peer是和其他组织节点通信的节点,可能对同步账本有影响。
    • core.yaml->peer->gossip->bootstrap 这里配置gossip初始的连接地址,合理的配置可能会影响账本同步的速度。
    • core.yaml->peer->gossip->externalEndpoint 设置这里的ip可以让外部组织的peer找到该peer。不太确定具体作用,但是可能会影响到该peer被其他peer发现。
  5. 裸机部署多节点(即不使用Docker),本想通过7051和8051部署两个Peer,但是 peer node start 的时候端口冲突报错。

    Error: failed to initialize operations subystems: listen tcp 127.0.0.1:9443: bind: address already in use
    

    看来单机多节点部署,只能使用docker了。

  6. 添加 TLS 报错:

    remote error: tls: bad certificate
    

    应该是证书问题,目前还未解决。

  7. 节点使用Couchdb报错:

    [200~Error calling CouchDB CreateDatabaseIfNotExist(for system dbName: _users, error: error decoding response body: json: cannot unmarshal string into Go struct field DBInfo.purge_seq of type int)]
    

    peer没有权限创建Couchdb已存在的表。
    解决方案:将Couchdb 2.3 版本切换到2.1.1后解决。
    切换方法,基于Docker:

    $ docker pull couchdb:2.1.1
    $ docker run -p 5984:5984 -d couchdb:2.1.1
    

    然后打开网址 http://127.0.0.1:5984/_utils/ 设置管理员用户名密码即可。

  8. 提交交易中包含较大数据的时候报错:

    [2019-01-30 18:45:50.755] [ERROR] invoke-chaincode - REQUEST_TIMEOUT:localhost:7051
    [2019-01-30 18:45:50.755] [ERROR] invoke-chaincode - Error: ChannelEventHub has been shutdown
        at ChannelEventHub.disconnect (/home/chengyang/Documents/ATL/ATLab-ATLChain/node_modules/fabric-client/lib/ChannelEventHub.js:516:21)
        at Timeout.setTimeout (/home/chengyang/Documents/ATL/ATLab-ATLChain/app/invoke-transaction.js:89:10)
        at ontimeout (timers.js:475:11)
        at tryOnTimeout (timers.js:310:5)
        at Timer.listOnTimeout (timers.js:270:5)
    [2019-01-30 18:45:50.755] [ERROR] invoke-chaincode - Error: ChannelEventHub has been shutdown
        at ChannelEventHub.disconnect (/home/chengyang/Documents/ATL/ATLab-ATLChain/node_modules/fabric-client/lib/ChannelEventHub.js:516:21)
        at Timeout.setTimeout (/home/chengyang/Documents/ATL/ATLab-ATLChain/app/invoke-transaction.js:89:10)
        at ontimeout (timers.js:475:11)
        at tryOnTimeout (timers.js:310:5)
        at Timer.listOnTimeout (timers.js:270:5)
    [2019-01-30 18:45:50.755] [ERROR] invoke-chaincode - Failed to invoke chaincode. cause:Error: ChannelEventHub has been shutdown
    (node:8938) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 6): Error: Failed to invoke chaincode. cause:Error: ChannelEventHub has been shutdown
    
    

    问题描述:我在提交的交易中加入了一个图片,经过简单测试,当图片大小超过 100K 的时候报该错误(但是偶尔也可以提交成功)。

    解决方案:尝试减小交易中的数据量。目前未能确定每次提交的时候是如何限制提交数据的大小的,但是从报错内容来看,应该不是直接显示提案的大小,可能是从响应时间上来限制的,数据量大时响应时间长,就超时报错。

  9. byfn 运行时报错:
    运行 ./byfn.sh up 的时候,报如下错误:

    Having all peers join the channel...
    + peer channel join -b mychannel.block
    + res=1
    + set +x
    Error: error getting endorser client for channel: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: context deadline exceeded
    peer0.org1 failed to join the channel, Retry after 3 seconds
    + peer channel join -b mychannel.block
    + res=1
    + set +x
    Error: error getting endorser client for channel: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: context deadline exceeded
    

    peer 节点容器启动后又关闭,导致执行 peer 节点加入 channel 的命令时不成功。查看 peer 容器日志 docker logs peer0.org1.example.com 如下:

    2019-02-21 08:12:05.380 UTC [nodeCmd] serve -> INFO 001 Starting peer:
     Version: 1.4.0
     Commit SHA: d700b43
     Go version: go1.11.1
     OS/Arch: linux/amd64
     Chaincode:
      Base Image Version: 0.4.14
      Base Docker Namespace: hyperledger
      Base Docker Label: org.hyperledger.fabric
      Docker Namespace: hyperledger
    2019-02-21 08:12:05.380 UTC [ledgermgmt] initialize -> INFO 002 Initializing ledger mgmt
    2019-02-21 08:12:05.380 UTC [kvledger] NewProvider -> INFO 003 Initializing ledger provider
    2019-02-21 08:12:05.451 UTC [kvledger] NewProvider -> INFO 004 ledger provider Initialized
    2019-02-21 08:12:05.513 UTC [ledgermgmt] initialize -> INFO 005 ledger mgmt initialized
    2019-02-21 08:12:05.514 UTC [peer] func1 -> INFO 006 Auto-detected peer address: 192.168.128.3:7051
    2019-02-21 08:12:05.514 UTC [peer] func1 -> INFO 007 Returning peer0.org1.example.com:7051
    2019-02-21 08:12:05.514 UTC [peer] func1 -> INFO 008 Auto-detected peer address: 192.168.128.3:7051
    2019-02-21 08:12:05.515 UTC [peer] func1 -> INFO 009 Returning peer0.org1.example.com:7051
    2019-02-21 08:12:05.517 UTC [nodeCmd] serve -> INFO 00a Starting peer with TLS enabled
    2019-02-21 08:12:05.520 UTC [nodeCmd] computeChaincodeEndpoint -> INFO 00b Entering computeChaincodeEndpoint with peerHostname: peer0.org1.example.com
    2019-02-21 08:12:05.521 UTC [nodeCmd] computeChaincodeEndpoint -> INFO 00c Exit with ccEndpoint: peer0.org1.example.com:7052
    2019-02-21 08:12:05.521 UTC [nodeCmd] createChaincodeServer -> WARN 00d peer.chaincodeListenAddress is not set, using peer0.org1.example.com:7052
    2019-02-21 08:12:05.531 UTC [sccapi] registerSysCC -> INFO 00e system chaincode lscc(github.com/hyperledger/fabric/core/scc/lscc) registered
    2019-02-21 08:12:05.531 UTC [sccapi] registerSysCC -> INFO 00f system chaincode cscc(github.com/hyperledger/fabric/core/scc/cscc) registered
    2019-02-21 08:12:05.531 UTC [sccapi] registerSysCC -> INFO 010 system chaincode qscc(github.com/hyperledger/fabric/core/scc/qscc) registered
    2019-02-21 08:12:05.531 UTC [sccapi] registerSysCC -> INFO 011 system chaincode (+lifecycle,github.com/hyperledger/fabric/core/chaincode/lifecycle,true) disabled
    2019-02-21 08:12:05.538 UTC [gossip.service] func1 -> INFO 012 Initialize gossip with endpoint peer0.org1.example.com:7051 and bootstrap set [peer1.org1.example.com:7051]
    2019-02-21 08:12:05.549 UTC [gossip.gossip] NewGossipService -> INFO 013 Creating gossip service with self membership of Endpoint: peer0.org1.example.com:7051, InternalEndpoint: peer0.org1.example.com:7051, PKI-ID: 95ea1f50253cc23fe5f809fbbc49596dd42c3502f4848ce3003ea27464236548, Metadata:
    2019-02-21 08:12:05.553 UTC [gossip.gossip] start -> INFO 014 Gossip instance peer0.org1.example.com:7051 started
    2019-02-21 08:12:05.553 UTC [sccapi] deploySysCC -> INFO 015 system chaincode lscc/(github.com/hyperledger/fabric/core/scc/lscc) deployed
    ** fatal error: unexpected signal during runtime execution **
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x63 pc=0x7f661833c259]
    
    runtime stack:
    runtime.throw(0x123f0ff, 0x2a)
        /opt/go/src/runtime/panic.go:608 +0x72
    runtime.sigpanic()
        /opt/go/src/runtime/signal_unix.go:374 +0x2f2
    
    goroutine 75 [syscall]:
    runtime.cgocall(0xe1bdc0, 0xc0002c6600, 0x29)
        /opt/go/src/runtime/cgocall.go:128 +0x5e fp=0xc0002c65c8 sp=0xc0002c6590 pc=0x4039ee
    net._C2func_getaddrinfo(0xc0003765c0, 0x0, 0xc00032ec00, 0xc00000e240, 0x0, 0x0, 0x0)
        _cgo_gotypes.go:92 +0x55 fp=0xc0002c6600 sp=0xc0002c65c8 pc=0x615b95
    net.cgoLookupIPCNAME.func1(0xc0003765c0, 0x0, 0xc00032ec00, 0xc00000e240, 0x17, 0x17, 0xbf13b535a108855c)
        /opt/go/src/net/cgo_unix.go:149 +0x131 fp=0xc0002c6648 sp=0xc0002c6600 pc=0x61b2b1
    net.cgoLookupIPCNAME(0xc00004415b, 0x16, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /opt/go/src/net/cgo_unix.go:149 +0x153 fp=0xc0002c6738 sp=0xc0002c6648 pc=0x617153
    net.cgoIPLookup(0xc000349140, 0xc00004415b, 0x16)
        /opt/go/src/net/cgo_unix.go:201 +0x4d fp=0xc0002c67c8 sp=0xc0002c6738 pc=0x61780d
    runtime.goexit()
        /opt/go/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc0002c67d0 sp=0xc0002c67c8 pc=0x45dc81
    created by net.cgoLookupIP
        /opt/go/src/net/cgo_unix.go:211 +0xad
    

    发现有一条报错 fatal error: unexpected signal during runtime execution

    解决方案:

    在 docker-compose-cli.yaml 中 cli 容器下,添加环境变量 GODEBUG=netdns=go,在 base/peer-base.yaml 中 peer-base 容器下,添加环境变量 GODEBUG=netdns=go

    参考文献: https://yq.aliyun.com/articles/238940

    解决方法二:如果以上方法不能解决问题,尝试修改 /etc/resolv.conf 文件:

    注释掉 options 的行,我修改后的文件如下,不同系统有些不同:

    nameserver 127.0.0.53
    # options edns0
    
上一篇 下一篇

猜你喜欢

热点阅读