Hyperledger入门学习教程

本文是作者“零基础”入门Hyperledger系列的日记性质的文章。笔者在区块链开发方面零基础,按照文中的顺序学习,三天内能够基本理解Hyperledger系列代码库的功用。


第一步:基础常识(0 hours)

区块链基础

区块链这个概念最近非常火,稍微对这方面有所关注的人都对区块链的核心思路有所了解。在笔者心目中,区块链,一个基于密码学的去中心化系统,该系统拥有不可篡改、匿名等特点。这一层面的理解,读者可以参考知乎上关于区块链的科普文章,在这里就不详细讲解了。

GO语言【可选】

除了比特币是用C++写的之外,大部分的区块链项目都是用GO语言写的,因为GO语言同时具有C++语言的效率,以及Java语言的安全性,广为高性能项目开发者所喜爱。后续的代码阅读需要对GO语言有基础的了解。当然,如果你只需要部署项目的话,Hyperledger已经有足够简单的脚本以致于不需要懂GO语言也能学会。

菜鸟教程:https://www.runoob.com/go/go-tutorial.html
C语言中文网教程:http://c.biancheng.net/golang/

第二步:阅读Hyperledger书籍 (2 hours)

尝试了解:Hyperledger的历史、存在意义以及算法基础。

网络对于Hyperledger的教程文章并不多,而且质量也并不太好,所以想要系统性的搞清楚联盟链有什么东西,可以看有关的书籍。我看的是下面这本书,由于微信阅读的免费卡真的厉害,在kindle上面30+RMB的书在微信阅读都是免费的——

笔者花了一个晚上的时间过了这本书的前几章,觉得重要的知识点有——

  • 区块链的分布式储存技术特性使得其本身就是一个很健壮的分布式数据库。
  • 一些有助于理解区块链原理的算法
    • 哈希算法,包括SHA-384, SHA-512等
    • Merkle树:用于对树形结构数据求得Hash值,高效,支持部分校验
    • 非对称加密:椭圆曲线,RSA加密算法
    • 共识机制:工作量证明(POW),股权证明(POS),委托权益证明(DPOS),拜占庭共识算法(PBFT),投注共识机制(Casper),消逝时间证明(POET)……
  • 智能合约的意义,智能合约本质是一段用某种计算编程语言编写的程序,这段程序可以运行在区块链系统提供的容器中。智能合约代码储存在区块链中,结合区块链提供的防篡改防伪造的特性,智能合约能够和区块链本身非常天然的融合在一起。
  • 区块链,特别是公链,有“性能慢”,“数据不易弹性扩展”,“技术社区不成熟”的缺点。
  • Hyperledger(超级账本)本身是Linux基金发起的推荐区块链技术和交易认证的开源项目。后来已经转变为一个开源的代码库集合,包含9个正式项目和50多个相关模块。其中,笔者最为关注的有
    • Hyperledger-Fabirc:Hyperledger核心项目,一个可灵活配置的分布式共享账本。
    • Hyperledger-Explorer: 一个基于Node.js的区块链配置管理,节点查询的工具。
    • Hyperledger-Burrow:一个智能合同机,采用了部分以太坊虚拟机(EVM)的技术规范。提供了共识引擎,合约引擎的接口。

第三步:理解Hyperledger的相关概念 (2 hours)

Hyperledger官方文档:https://hyperledger-fabric.readthedocs.io/en/master/key_concepts.html
民间总结:https://hackernoon.com/hyperledger-fabric-the-20-most-important-terms-made-simple-2753f925db4

这一步我们需要尝试了解Hyperledger的常用术语,包括Consensus、Policy、Peers、Ledger等概念。

这些概念非常重要,原因是在后续的部署中,我们可能遇到类似于peer chaincode invoke 这样的命令,如果读者连这些名词的具体含义都没有了解的话,在后续的部署中会觉得很难受。

读者可以现在先对这些概念有一个初步的映像,在后续部署过程中遇到的时候,再有针对性的去阅读。

这些概念,可以在Hyperledger Fabric的文档中了解。

重要知识点——

Policy
policy,是一系列规则,描述了决策该如何指定,结果是如何产生的。可以类比于我们平常的“保险协议”,定义了理赔的范围、时间等信息。事实上,hyperledger-fabric的policy和比特币、以太坊等项目的policy有所不同,后者的policy是固定的,过去、现在、未来都不会变。但是hyperledger-fabric则支持网络的所有者,不仅可以在网络运行之前制定规则,还可以在网络运行的时候修改规则。

Peers
peers,对等节点,是网络上的最基本的元素。区块链网络的对等节点内部储存了账单以及智能合约的拷贝。Peer可以被创建、启动、暂停、删除,并且他们暴露了一系列API供管理人员以及服务需求商调用。

Ledger
Ledger 是账单的意思,ledger被储存在peer节点中,通过一系列方式保证了账单的同步。

Chaincode
chaincode,合约代码,和ledger一样储存在peer节点中,而chaincode定义了用来访问ledger的代码。

Orderer
orderer,请求者,可以理解为用户和整个peers网络节点的一个终结。orderer在整个联盟统一的条件下被加入联盟链,拥有权限创建一个交易,并且让所有peers同步这个交易。

第三步:Hyperledger Fabric部署 (4 hours)

首先按照入门教程中的引导,我们可以使用fabric-samples这个库中提供的脚本,在docker环境中跑一个简易的Hyperledger版本。具体来说,我们接下来,将使用fabric-samples/test-network的脚本,一步一步建立起一个网络,这个网络能够记录一系列车辆的信息。

首先我们搭建环境,在工作目录执行

curl -sSL https://bit.ly/2ysbOFE | bash -s

这一个指令干了三件事情——

  • 倘若工作目录下没有fabric-samples,则从github将这个库clone下来
  • 从github的fabric仓库下载可执行文件,放在fabric-samples/bin目录下
  • 从dockerhub上面拉取需要的docker镜像文件

这一步指令可能存在翻墙的问题,如果遇到了的话,可能就需要根据具体情况“挂代理”“改hosts”或“设镜像”。

接下来我们按照测试网络搭建教程中的命令执行指令。这些指令将一步一步建立起整个联盟链,推荐直接去看原文。

进入测试网络的目录

cd fabric-samples/test-network/

开启网络,建立网络中的三个节点

  • orderer.example.com
  • peer0.org1.example.com
  • peer0.org2.example.com

这三个节点每一个都是一个独立的docker容器,其中peer节点一定要依附于某个组织,而orderer节点可以独立存在。命令输出见附录A

./network.sh up

接下来使用命令建立一个channel:

./network.sh createChannel

命令输出见附录B

接下来,使用命令建立一个ChainCode(这里因为要下载GO包,叒需要翻墙了)

./network.sh deployCC

该指令首先安装chaincode的依赖库,然后将chaincode分别安装到两个peer中,接着再将chaincode部署到channel中。具体输出见附录C,可以看到,一些“汽车”的数据被加入了我们的账本——

[{"Key":"CAR0","Record":{"make":"Toyota","model":"Prius","colour":"blue","owner":"Tomoko"}},{"Key":"CAR1","Record":{"make":"Ford","model":"Mustang","colour":"red","owner":"Brad"}},{"Key":"CAR2","Record":{"make":"Hyundai","model":"Tucson","colour":"green","owner":"Jin Soo"}},{"Key":"CAR3","Record":{"make":"Volkswagen","model":"Passat","colour":"yellow","owner":"Max"}},{"Key":"CAR4","Record":{"make":"Tesla","model":"S","colour":"black","owner":"Adriana"}},{"Key":"CAR5","Record":{"make":"Peugeot","model":"205","colour":"purple","owner":"Michel"}},{"Key":"CAR6","Record":{"make":"Chery","model":"S22L","colour":"white","owner":"Aarav"}},{"Key":"CAR7","Record":{"make":"Fiat","model":"Punto","colour":"violet","owner":"Pari"}},{"Key":"CAR8","Record":{"make":"Tata","model":"Nano","colour":"indigo","owner":"Valeria"}},{"Key":"CAR9","Record":{"make":"Holden","model":"Barina","colour":"brown","owner":"Shotaro"}}]

现在,一切初始化操作已经就绪,我们可以开始与我们的网络进行交互。首先确认位于test-network目录,配置环境变量——

export PATH={PWD}/../bin:{PWD}:PATH export FABRIC_CFG_PATH=PWD/../config/
# Environment variables for Org1
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE={PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt export CORE_PEER_MSPCONFIGPATH={PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
export CORE_PEER_ADDRESS=localhost:7051

接下来,我们使用一个命令查询账本中的数据:

peer chaincode query -C mychannel -n fabcar -c '{"Args":["queryAllCars"]}'

结果与deployCC的输出结果相同。

使用下面的命令可以对账本进行修改,

peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls true --cafile {PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n fabcar --peerAddresses localhost:7051 --tlsRootCertFiles{PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"function":"changeCarOwner","Args":["CAR9","Dave"]}'

虽然命令的功能可以从字面意思翻译出来,我们还是可以用help命令自习看一看具体每个参数可以怎么用。

peer命令本身可以看做是一个入口命令,里面分为了peer node操作节点,peer channel 操作频道,peer chaincode 操作合约代码。

其中peer chaincode进一步又有installinvoke等子命令。

在之后的第四步中,我们会使用./first-network而非现在的./test-network,所以需要将现在的网络关闭。结果如附录d。

./network.sh down

第四步,部署hyperledger-explorer

项目仓库:https://github.com/hyperledger/blockchain-explorer
非官方安装教程:https://medium.com/coinmonks/hyperledger-explorer-quick-start-50a49c6d7957
官方安装教程:https://github.com/hyperledger/blockchain-explorer#Database-Setup

hyperledger-explorer的部署需要依赖挺多的东西的,单纯安装环境就需要比较长的时间。这一步推荐同时看官方/非官方教程,因为非官方教程有些地方有点过时。

修改nodejs版本

which node
npm install -g n
sudo n 8.11.1
node --version

安装PostgreSQL、jq

brew install postgres
brew install jq

开启Fabric,由于在上一步已经启动了一个Fabric网络,其中临时设置了一些环境变量,所以这里推荐重启终端以消除影响

首先安装GO库

go get github.com/hyperledger/fabric/core/chaincode/shim

接着启动./first-network,这一步需要逐一输出有没有报错,如果有报错的话,不应该继续下去。

cd ./first-network/
./byfn.sh generate
./byfn.sh up

下载blockchain-explorer

git clone https://github.com/hyperledger/blockchain-explorer.git

开启PostgreSQL,并初始化数据库

pg_ctl -D /usr/local/var/postgres start
cd ./blockchain-explorer/app/persistence/fabric/postgreSQL/db
./createdb.sh

查看配置文件vim ./blockchain-explorer/app/platform/fabric/config.json 由于配置文件默认引用了./connection-profile/first-network.json,所以我们需要按照官方文档的指引,稍微修改一下这一部分,包括——

  • 修改配置文件中fabric-path这个字符串为./fabric-samples所在的真实绝对路径。
  • 修改配置文件中以_sk结尾的文件为真实文件名,在我这里是priv_sk

安装npm依赖包

cd ./blockchain-explorer
./main install
./main test

如果安装正确,应该能够通过所有测试。最后执行命令

./start.sh

这个命令没有控制行输出,所有输出被丛定祥到./logs目录下,如果没有成功运行,可以在这个目录的./app/app.log日志里面找原因。如果成功运行,则在http://127.0.0.1:8080/#/这里可以看到浏览器。(这个字号以及右上角的图标栏是真的丑)

附录

A. 命令./network.sh up输出

Starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb' with crypto from 'cryptogen'

LOCAL_VERSION=2.0.0
DOCKER_IMAGE_VERSION=2.0.0
/Users/toby/Workspace/fabric-samples/test-network/../bin/cryptogen

##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################

##########################################################
############ Create Org1 Identities ######################
##########################################################
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output=organizations
org1.example.com
+ res=0
+ set +x
##########################################################
############ Create Org2 Identities ######################
##########################################################
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output=organizations
org2.example.com
+ res=0
+ set +x
##########################################################
############ Create Orderer Org Identities ###############
##########################################################
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output=organizations
+ res=0
+ set +x

Generate CCP files for Org1 and Org2
/Users/toby/Workspace/fabric-samples/test-network/../bin/configtxgen
#########  Generating Orderer Genesis block ##############
+ configtxgen -profile TwoOrgsOrdererGenesis -channelID system-channel -outputBlock ./system-genesis-block/genesis.block
2020-03-10 18:43:19.430 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-03-10 18:43:19.453 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: etcdraft
2020-03-10 18:43:19.454 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 Orderer.EtcdRaft.Options unset, setting to tick_interval:"500ms" election_tick:10 heartbeat_tick:1 max_inflight_blocks:5 snapshot_interval_size:16777216
2020-03-10 18:43:19.454 CST [common.tools.configtxgen.localconfig] Load -> INFO 004 Loaded configuration: /Users/toby/Workspace/fabric-samples/test-network/configtx/configtx.yaml
2020-03-10 18:43:19.458 CST [common.tools.configtxgen] doOutputBlock -> INFO 005 Generating genesis block
2020-03-10 18:43:19.458 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Writing genesis block
+ res=0
+ set +x
Creating network "net_test" with the default driver
Creating volume "net_orderer.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating peer0.org2.example.com ... done
Creating peer0.org1.example.com ... done
Creating orderer.example.com    ... done
CONTAINER ID        IMAGE                               COMMAND                  CREATED             STATUS                     PORTS                              NAMES
f52d0319b985        hyperledger/fabric-orderer:latest   "orderer"                1 second ago        Up Less than a second      0.0.0.0:7050->7050/tcp             orderer.example.com
163555ca9cc3        hyperledger/fabric-peer:latest      "peer node start"        1 second ago        Up Less than a second      0.0.0.0:7051->7051/tcp             peer0.org1.example.com
e73c49a212eb        hyperledger/fabric-peer:latest      "peer node start"        1 second ago        Up Less than a second      7051/tcp, 0.0.0.0:9051->9051/tcp   peer0.org2.example.com

B. 命令./network.sh createChannel输出

Creating channel 'mychannel'.

If network is not up, starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb

### Generating channel configuration transaction 'mychannel.tx' ###
+ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/mychannel.tx -channelID mychannel
2020-03-10 20:09:40.336 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-03-10 20:09:40.358 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /Users/toby/Workspace/fabric-samples/test-network/configtx/configtx.yaml
2020-03-10 20:09:40.358 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 003 Generating new channel configtx
2020-03-10 20:09:40.364 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 004 Writing new channel tx
+ res=0
+ set +x

### Generating channel configuration transaction 'mychannel.tx' ###
#######    Generating anchor peer update for Org1MSP  ##########
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP
2020-03-10 20:09:40.397 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-03-10 20:09:40.415 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /Users/toby/Workspace/fabric-samples/test-network/configtx/configtx.yaml
2020-03-10 20:09:40.415 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update
2020-03-10 20:09:40.418 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update
+ res=0
+ set +x

#######    Generating anchor peer update for Org2MSP  ##########
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP
2020-03-10 20:09:40.449 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-03-10 20:09:40.468 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /Users/toby/Workspace/fabric-samples/test-network/configtx/configtx.yaml
2020-03-10 20:09:40.468 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update
2020-03-10 20:09:40.470 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update
+ res=0
+ set +x

Creating channel mychannel
Using organization 1
+ peer channel create -o localhost:7050 -c mychannel --ordererTLSHostnameOverride orderer.example.com -f ./channel-artifacts/mychannel.tx --outputBlock ./channel-artifacts/mychannel.block --tls true --cafile /Users/toby/Workspace/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2020-03-10 20:09:43.694 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-03-10 20:09:43.722 CST [cli.common] readBlock -> INFO 002 Expect block, but got status: &{NOT_FOUND}
2020-03-10 20:09:43.726 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2020-03-10 20:09:43.931 CST [cli.common] readBlock -> INFO 004 Expect block, but got status: &{SERVICE_UNAVAILABLE}
2020-03-10 20:09:43.935 CST [channelCmd] InitCmdFactory -> INFO 005 Endorser and orderer connections initialized
2020-03-10 20:09:44.141 CST [cli.common] readBlock -> INFO 006 Expect block, but got status: &{SERVICE_UNAVAILABLE}
2020-03-10 20:09:44.146 CST [channelCmd] InitCmdFactory -> INFO 007 Endorser and orderer connections initialized
2020-03-10 20:09:44.354 CST [cli.common] readBlock -> INFO 008 Expect block, but got status: &{SERVICE_UNAVAILABLE}
2020-03-10 20:09:44.359 CST [channelCmd] InitCmdFactory -> INFO 009 Endorser and orderer connections initialized
2020-03-10 20:09:44.564 CST [cli.common] readBlock -> INFO 00a Expect block, but got status: &{SERVICE_UNAVAILABLE}
2020-03-10 20:09:44.568 CST [channelCmd] InitCmdFactory -> INFO 00b Endorser and orderer connections initialized
2020-03-10 20:09:44.773 CST [cli.common] readBlock -> INFO 00c Received block: 0

===================== Channel 'mychannel' created =====================

Join Org1 peers to the channel...
Using organization 1
+ peer channel join -b ./channel-artifacts/mychannel.block
+ res=0
+ set +x
2020-03-10 20:09:47.847 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-03-10 20:09:47.873 CST [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel

Join Org2 peers to the channel...
Using organization 2
+ peer channel join -b ./channel-artifacts/mychannel.block
+ res=0
+ set +x
2020-03-10 20:09:50.943 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-03-10 20:09:50.970 CST [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel

Updating anchor peers for org1...
Using organization 1
+ peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c mychannel -f ./channel-artifacts/Org1MSPanchors.tx --tls true --cafile /Users/toby/Workspace/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2020-03-10 20:09:51.025 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-03-10 20:09:51.038 CST [channelCmd] update -> INFO 002 Successfully submitted channel update
===================== Anchor peers updated for org 'Org1MSP' on channel 'mychannel' =====================

Updating anchor peers for org2...
Using organization 2
+ peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c mychannel -f ./channel-artifacts/Org2MSPanchors.tx --tls true --cafile /Users/toby/Workspace/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2020-03-10 20:09:54.097 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-03-10 20:09:54.115 CST [channelCmd] update -> INFO 002 Successfully submitted channel update
===================== Anchor peers updated for org 'Org2MSP' on channel 'mychannel' =====================


========= Channel successfully joined ===========

C. 命令./network.sh createChannel的输出结果

deploying chaincode on channel 'mychannel'

Vendoring Go dependencies ...
~/Workspace/fabric-samples/chaincode/fabcar/go ~/Workspace/fabric-samples/test-network
go: finding github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63
go: finding github.com/spf13/pflag v1.0.3
go: finding github.com/spf13/viper v1.3.2
go: finding github.com/inconshreveable/mousetrap v1.0.0
go: finding golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
go: finding golang.org/x/sys v0.0.0-20190710143415-6ec70d6a5542
go: finding golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
go: finding golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f
go: finding golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59
go: finding golang.org/x/tools v0.0.0-20180221164845-07fd8470d635
go: finding golang.org/x/text v0.3.2
go: finding github.com/cpuguy83/go-md2man v1.0.10
go: finding golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8
go: finding github.com/mitchellh/go-homedir v1.1.0
go: finding github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6
go: finding golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e
go: finding github.com/hashicorp/hcl v1.0.0
go: finding github.com/spf13/cast v1.3.0
go: finding github.com/spf13/jwalterweatherman v1.0.0
go: finding golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a
go: finding golang.org/x/text v0.3.0
go: finding github.com/russross/blackfriday v1.5.2
go: finding github.com/spf13/afero v1.1.2
go: finding github.com/fsnotify/fsnotify v1.4.7
go: finding github.com/magiconair/properties v1.8.0
go: finding github.com/coreos/go-semver v0.2.0
go: finding github.com/pelletier/go-toml v1.2.0
go: finding golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
go: finding github.com/coreos/etcd v3.3.10+incompatible
go: finding golang.org/x/tools v0.0.0-20190311212946-11955173bddd
go: finding github.com/mitchellh/mapstructure v1.1.2
go: finding gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
go: finding github.com/coreos/go-etcd v2.0.0+incompatible
go: finding github.com/stretchr/testify v1.2.2
go: finding github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8
go: finding github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77
go: finding golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9
go: finding github.com/kr/pty v1.1.1
go: finding golang.org/x/sys v0.0.0-20190515120540-06a5c4944438
go: finding golang.org/x/sys v0.0.0-20190412213103-97732733099d
go: finding golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
go: finding github.com/stretchr/objx v0.1.1
go: finding github.com/konsorten/go-windows-terminal-sequences v1.0.1
go: finding golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4
go: finding github.com/go-openapi/swag v0.19.2
go: finding golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c
go: finding golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135
go: finding golang.org/x/sys v0.0.0-20190422165155-953cdadca894
go: downloading github.com/hyperledger/fabric-contract-api-go v1.0.0
go: downloading github.com/xeipuuv/gojsonschema v1.2.0
go: downloading github.com/hyperledger/fabric-protos-go v0.0.0-20200124220212-e9cfc186ba7b
go: downloading github.com/hyperledger/fabric-chaincode-go v0.0.0-20200128192331-2d899240a7ed
go: downloading github.com/go-openapi/spec v0.19.4
go: downloading github.com/gobuffalo/packr v1.30.1
go: downloading github.com/golang/protobuf v1.3.2
go: downloading google.golang.org/grpc v1.23.0
go: downloading github.com/gobuffalo/envy v1.7.0
go: downloading golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4
go: downloading github.com/gobuffalo/packd v0.3.0
go: downloading github.com/joho/godotenv v1.3.0
go: downloading github.com/go-openapi/jsonreference v0.19.2
go: downloading github.com/go-openapi/swag v0.19.5
go: downloading github.com/rogpeppe/go-internal v1.3.0
go: downloading github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415
go: downloading github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e
go: downloading github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f
go: downloading golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297
go: downloading gopkg.in/yaml.v2 v2.2.2
go: downloading github.com/go-openapi/jsonpointer v0.19.3
go: downloading golang.org/x/sys v0.0.0-20190710143415-6ec70d6a5542
go: downloading github.com/PuerkitoBio/purell v1.1.1
go: downloading google.golang.org/genproto v0.0.0-20180831171423-11092d34479b
go: downloading golang.org/x/text v0.3.2
go: downloading github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578
~/Workspace/fabric-samples/test-network
Finished vendoring Go dependencies
Using organization 1
++ peer lifecycle chaincode package fabcar.tar.gz --path ../chaincode/fabcar/go/ --lang golang --label fabcar_1
++ res=0
++ set +x
===================== Chaincode is packaged on peer0.org1 =====================

Installing chaincode on peer0.org1...
Using organization 1
++ peer lifecycle chaincode install fabcar.tar.gz
++ res=0
++ set +x
2020-03-10 20:45:03.834 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nIfabcar_1:26fb56d416d999e58bd47a1381717065c66abad574736ae11518073fb8c2a747\022\010fabcar_1" >
2020-03-10 20:45:03.835 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: fabcar_1:26fb56d416d999e58bd47a1381717065c66abad574736ae11518073fb8c2a747
===================== Chaincode is installed on peer0.org1 =====================

Install chaincode on peer0.org2...
Using organization 2
++ peer lifecycle chaincode install fabcar.tar.gz
++ res=0
++ set +x
2020-03-10 20:45:19.446 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nIfabcar_1:26fb56d416d999e58bd47a1381717065c66abad574736ae11518073fb8c2a747\022\010fabcar_1" >
2020-03-10 20:45:19.446 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: fabcar_1:26fb56d416d999e58bd47a1381717065c66abad574736ae11518073fb8c2a747
===================== Chaincode is installed on peer0.org2 =====================

Using organization 1
++ peer lifecycle chaincode queryinstalled
++ res=0
++ set +x
Installed chaincodes on peer:
Package ID: fabcar_1:26fb56d416d999e58bd47a1381717065c66abad574736ae11518073fb8c2a747, Label: fabcar_1
PackageID is fabcar_1:26fb56d416d999e58bd47a1381717065c66abad574736ae11518073fb8c2a747
===================== Query installed successful on peer0.org1 on channel =====================

Using organization 1
++ peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls true --cafile /Users/toby/Workspace/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name fabcar --version 1 --init-required --package-id fabcar_1:26fb56d416d999e58bd47a1381717065c66abad574736ae11518073fb8c2a747 --sequence 1
++ set +x
2020-03-10 20:45:21.675 CST [chaincodeCmd] ClientWait -> INFO 001 txid [45755d771fb952c6a9d251c8be3a011edabc50b861bb82b3b8bb0f9a31c3ad6a] committed with status (VALID) at
===================== Chaincode definition approved on peer0.org1 on channel 'mychannel' =====================

Using organization 1
===================== Checking the commit readiness of the chaincode definition on peer0.org1 on channel 'mychannel'... =====================
Attempting to check the commit readiness of the chaincode definition on peer0.org1 secs
++ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name fabcar --version 1 --sequence 1 --output json --init-required
++ res=0
++ set +x
{
	"approvals": {
		"Org1MSP": true,
		"Org2MSP": false
	}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel 'mychannel' =====================
Using organization 2
===================== Checking the commit readiness of the chaincode definition on peer0.org2 on channel 'mychannel'... =====================
Attempting to check the commit readiness of the chaincode definition on peer0.org2 secs
++ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name fabcar --version 1 --sequence 1 --output json --init-required
++ res=0
++ set +x
{
	"approvals": {
		"Org1MSP": true,
		"Org2MSP": false
	}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel 'mychannel' =====================
Using organization 2
++ peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls true --cafile /Users/toby/Workspace/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name fabcar --version 1 --init-required --package-id fabcar_1:26fb56d416d999e58bd47a1381717065c66abad574736ae11518073fb8c2a747 --sequence 1
++ set +x
2020-03-10 20:45:29.955 CST [chaincodeCmd] ClientWait -> INFO 001 txid [d102dff36c7e097155b0209f8e211d2ca9c0c8d487ea7d3fc837d13b9d48c19e] committed with status (VALID) at
===================== Chaincode definition approved on peer0.org2 on channel 'mychannel' =====================

Using organization 1
===================== Checking the commit readiness of the chaincode definition on peer0.org1 on channel 'mychannel'... =====================
Attempting to check the commit readiness of the chaincode definition on peer0.org1 secs
++ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name fabcar --version 1 --sequence 1 --output json --init-required
++ res=0
++ set +x
{
	"approvals": {
		"Org1MSP": true,
		"Org2MSP": true
	}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel 'mychannel' =====================
Using organization 2
===================== Checking the commit readiness of the chaincode definition on peer0.org2 on channel 'mychannel'... =====================
Attempting to check the commit readiness of the chaincode definition on peer0.org2 secs
++ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name fabcar --version 1 --sequence 1 --output json --init-required
++ res=0
++ set +x
{
	"approvals": {
		"Org1MSP": true,
		"Org2MSP": true
	}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel 'mychannel' =====================
Using organization 1
Using organization 2
++ peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls true --cafile /Users/toby/Workspace/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name fabcar --peerAddresses localhost:7051 --tlsRootCertFiles /Users/toby/Workspace/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles /Users/toby/Workspace/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --version 1 --sequence 1 --init-required
++ res=0
++ set +x
2020-03-10 20:45:38.425 CST [chaincodeCmd] ClientWait -> INFO 001 txid [6315e52c4b5e435f53b1d10fe6c68d796b8859a93a9bceb27a68179e35a01979] committed with status (VALID) at localhost:7051
2020-03-10 20:45:38.433 CST [chaincodeCmd] ClientWait -> INFO 002 txid [6315e52c4b5e435f53b1d10fe6c68d796b8859a93a9bceb27a68179e35a01979] committed with status (VALID) at localhost:9051
===================== Chaincode definition committed on channel 'mychannel' =====================

Using organization 1
===================== Querying chaincode definition on peer0.org1 on channel 'mychannel'... =====================
Attempting to Query committed status on peer0.org1, Retry after 3 seconds.
++ peer lifecycle chaincode querycommitted --channelID mychannel --name fabcar
++ res=0
++ set +x

Committed chaincode definition for chaincode 'fabcar' on channel 'mychannel':
Version: 1, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
===================== Query chaincode definition successful on peer0.org1 on channel 'mychannel' =====================

Using organization 2
===================== Querying chaincode definition on peer0.org2 on channel 'mychannel'... =====================
Attempting to Query committed status on peer0.org2, Retry after 3 seconds.
++ peer lifecycle chaincode querycommitted --channelID mychannel --name fabcar
++ res=0
++ set +x

Committed chaincode definition for chaincode 'fabcar' on channel 'mychannel':
Version: 1, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
===================== Query chaincode definition successful on peer0.org2 on channel 'mychannel' =====================

Using organization 1
Using organization 2
++ peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls true --cafile /Users/toby/Workspace/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n fabcar --peerAddresses localhost:7051 --tlsRootCertFiles /Users/toby/Workspace/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles /Users/toby/Workspace/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --isInit -c '{"function":"initLedger","Args":[]}'
++ res=0
++ set +x
2020-03-10 20:45:44.696 CST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
===================== Invoke transaction successful on peer0.org1 peer0.org2 on channel 'mychannel' =====================

Using organization 1
Using organization 2
++ peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls true --cafile /Users/toby/Workspace/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n fabcar --peerAddresses localhost:7051 --tlsRootCertFiles /Users/toby/Workspace/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles /Users/toby/Workspace/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"function":"initLedger","Args":[]}'
++ res=0
++ set +x
2020-03-10 20:45:54.795 CST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
===================== Invoke transaction successful on peer0.org1 peer0.org2 on channel 'mychannel' =====================

Querying chaincode on peer0.org1...
Using organization 1
===================== Querying on peer0.org1 on channel 'mychannel'... =====================
Attempting to Query peer0.org1 ...1583844357 secs
++ peer chaincode query -C mychannel -n fabcar -c '{"Args":["queryAllCars"]}'
++ res=0
++ set +x

[{"Key":"CAR0","Record":{"make":"Toyota","model":"Prius","colour":"blue","owner":"Tomoko"}},{"Key":"CAR1","Record":{"make":"Ford","model":"Mustang","colour":"red","owner":"Brad"}},{"Key":"CAR2","Record":{"make":"Hyundai","model":"Tucson","colour":"green","owner":"Jin Soo"}},{"Key":"CAR3","Record":{"make":"Volkswagen","model":"Passat","colour":"yellow","owner":"Max"}},{"Key":"CAR4","Record":{"make":"Tesla","model":"S","colour":"black","owner":"Adriana"}},{"Key":"CAR5","Record":{"make":"Peugeot","model":"205","colour":"purple","owner":"Michel"}},{"Key":"CAR6","Record":{"make":"Chery","model":"S22L","colour":"white","owner":"Aarav"}},{"Key":"CAR7","Record":{"make":"Fiat","model":"Punto","colour":"violet","owner":"Pari"}},{"Key":"CAR8","Record":{"make":"Tata","model":"Nano","colour":"indigo","owner":"Valeria"}},{"Key":"CAR9","Record":{"make":"Holden","model":"Barina","colour":"brown","owner":"Shotaro"}}]
===================== Query successful on peer0.org1 on channel 'mychannel' =====================

D. 命令./network.sh down 运行结果

Stopping network

Stopping orderer.example.com    ... done
Stopping peer0.org1.example.com ... done
Stopping peer0.org2.example.com ... done
Removing orderer.example.com    ... done
Removing peer0.org1.example.com ... done
Removing peer0.org2.example.com ... done
Removing network net_default
WARNING: Network net_default not found.
Removing network net_test
Removing volume net_orderer.example.com
Removing volume net_peer0.org1.example.com
Removing volume net_peer0.org2.example.com
Removing network net_test
WARNING: Network net_test not found.
Removing volume net_peer0.org3.example.com
WARNING: Volume net_peer0.org3.example.com not found.
9e8c15a64cbe
a4072998f502
Untagged: dev-peer0.org2.example.com-fabcar_1-26fb56d416d999e58bd47a1381717065c66abad574736ae11518073fb8c2a747-26cde13f78aa8eff73d4744d561a8b137c9eda176ba8a84d36af48a8c9de631c:latest
Deleted: sha256:dc700dd2db09006dd2fce3342fae1216b25e9d38f041b6a0939cebd7028926a8
Deleted: sha256:c407d2e27d1274d907f5951233dd4be58a316d9b044e2ab0c11d760a83de2e95
Deleted: sha256:01895489c6d960088a38bc3900a9f95304033265bcdaed8c4d3a98b8de94b49c
Deleted: sha256:ba1afd3832d77b10bec39ffda37b1db034d74b0564c8ebb70d857bc6b55a1338
Untagged: dev-peer0.org1.example.com-fabcar_1-26fb56d416d999e58bd47a1381717065c66abad574736ae11518073fb8c2a747-61a1af104025983f31a73f6b597bc3a2bf3bc5f680287147657ca79e648bb813:latest
Deleted: sha256:28b9dda318f39b007764e52b6be09ddfea61a208dc4c0baa2963b3f76564c0e6
Deleted: sha256:6bf70e8ade3bf7e98468a901e146f32b8c550b5ba75470cecccaa88030144b74
Deleted: sha256:329afa3cc5d41c17306a013014f3ca7621f7469e969ce500826426414b1d98b1
Deleted: sha256:24d8a9329711871ebe3ac33cdccfa6453c1d584313f0875809529af348301933

First-Network的./byfn.sh up运行结果

./byfn.sh up
Starting for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] y
proceeding ...
LOCAL_VERSION=2.0.0
DOCKER_IMAGE_VERSION=2.0.0
Creating network "net_byfn" with the default driver
Creating volume "net_orderer.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_peer1.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating volume "net_peer1.org2.example.com" with default driver
Creating volume "net_orderer2.example.com" with default driver
Creating volume "net_orderer3.example.com" with default driver
Creating volume "net_orderer4.example.com" with default driver
Creating volume "net_orderer5.example.com" with default driver
Creating peer1.org1.example.com ... done
Creating peer1.org2.example.com ... done
Creating peer0.org1.example.com ... done
Creating orderer2.example.com   ... done
Creating orderer3.example.com   ... done
Creating orderer.example.com    ... done
Creating orderer4.example.com   ... done
Creating peer0.org2.example.com ... done
Creating orderer5.example.com   ... done
Creating cli                    ... done
CONTAINER ID        IMAGE                               COMMAND             CREATED             STATUS                  PORTS                                NAMES
e32aad7014ed        hyperledger/fabric-tools:latest     "/bin/bash"         1 second ago        Up Less than a second                                        cli
1249b849b0a9        hyperledger/fabric-orderer:latest   "orderer"           4 seconds ago       Up Less than a second   7050/tcp, 0.0.0.0:10050->10050/tcp   orderer4.example.com
6a6f47c0ee97        hyperledger/fabric-orderer:latest   "orderer"           4 seconds ago       Up Less than a second   7050/tcp, 0.0.0.0:8050->8050/tcp     orderer2.example.com
4220ce4e0ea7        hyperledger/fabric-peer:latest      "peer node start"   4 seconds ago       Up 1 second             7051/tcp, 0.0.0.0:9051->9051/tcp     peer0.org2.example.com
3be50ae18707        hyperledger/fabric-orderer:latest   "orderer"           4 seconds ago       Up 1 second             7050/tcp, 0.0.0.0:11050->11050/tcp   orderer5.example.com
b8e736266e0c        hyperledger/fabric-peer:latest      "peer node start"   4 seconds ago       Up 2 seconds            7051/tcp, 0.0.0.0:10051->10051/tcp   peer1.org2.example.com
597566c99ea5        hyperledger/fabric-orderer:latest   "orderer"           4 seconds ago       Up 2 seconds            7050/tcp, 0.0.0.0:9050->9050/tcp     orderer3.example.com
04dd5781d0bd        hyperledger/fabric-orderer:latest   "orderer"           4 seconds ago       Up 2 seconds            0.0.0.0:7050->7050/tcp               orderer.example.com
53a140d598be        hyperledger/fabric-peer:latest      "peer node start"   4 seconds ago       Up 2 seconds            0.0.0.0:7051->7051/tcp               peer0.org1.example.com
c6f4104d41b7        hyperledger/fabric-peer:latest      "peer node start"   4 seconds ago       Up 2 seconds            7051/tcp, 0.0.0.0:8051->8051/tcp     peer1.org1.example.com
Sleeping 15s to allow Raft cluster to complete booting
Vendoring Go dependencies ...
~/Workspace/fabric-samples/chaincode/abstore/go ~/Workspace/fabric-samples/first-network
go: finding golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7
go: finding golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a
go: finding google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55
go: finding golang.org/x/tools v0.0.0-20190226205152-f727befe758c
go: finding golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961
go: finding golang.org/x/exp v0.0.0-20190121172915-509febef88a4
go: finding golang.org/x/net v0.0.0-20190213061140-3a22650c66bd
go: finding google.golang.org/grpc v1.19.0
go: finding golang.org/x/sync v0.0.0-20181108010431-42b317875d0f
go: finding google.golang.org/appengine v1.4.0
go: finding honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099
go: finding golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3
go: finding golang.org/x/tools v0.0.0-20190114222345-bf090417da8b
go: finding golang.org/x/net v0.0.0-20180826012351-8a410e7b638d
go: finding golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
go: finding golang.org/x/sys v0.0.0-20180830151530-49385e6e1522
go: finding golang.org/x/net v0.0.0-20180724234803-3673e40ba225
go: downloading github.com/hyperledger/fabric-protos-go v0.0.0-20190821214336-621b908d5022
go: downloading github.com/hyperledger/fabric-chaincode-go v0.0.0-20190823162523-04390e015b85
go: downloading golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
go: downloading golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7
go: downloading google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55
go: downloading golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a
~/Workspace/fabric-samples/first-network
Finished vendoring Go dependencies

 ____    _____      _      ____    _____
/ ___|  |_   _|    / \    |  _ \  |_   _|
\___ \    | |     / _ \   | |_) |   | |
 ___) |   | |    / ___ \  |  _ <    | |
|____/    |_|   /_/   \_\ |_| \_\   |_|

Build your first network (BYFN) end-to-end test

Channel name : mychannel
Creating channel...
+ peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2020-03-18 08:32:09.299 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-03-18 08:32:09.416 UTC [cli.common] readBlock -> INFO 002 Expect block, but got status: &{NOT_FOUND}
2020-03-18 08:32:09.477 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2020-03-18 08:32:09.680 UTC [cli.common] readBlock -> INFO 004 Expect block, but got status: &{SERVICE_UNAVAILABLE}
2020-03-18 08:32:09.711 UTC [channelCmd] InitCmdFactory -> INFO 005 Endorser and orderer connections initialized
2020-03-18 08:32:09.914 UTC [cli.common] readBlock -> INFO 006 Expect block, but got status: &{SERVICE_UNAVAILABLE}
2020-03-18 08:32:09.931 UTC [channelCmd] InitCmdFactory -> INFO 007 Endorser and orderer connections initialized
2020-03-18 08:32:10.134 UTC [cli.common] readBlock -> INFO 008 Expect block, but got status: &{SERVICE_UNAVAILABLE}
2020-03-18 08:32:10.156 UTC [channelCmd] InitCmdFactory -> INFO 009 Endorser and orderer connections initialized
2020-03-18 08:32:10.358 UTC [cli.common] readBlock -> INFO 00a Expect block, but got status: &{SERVICE_UNAVAILABLE}
2020-03-18 08:32:10.377 UTC [channelCmd] InitCmdFactory -> INFO 00b Endorser and orderer connections initialized
2020-03-18 08:32:10.583 UTC [cli.common] readBlock -> INFO 00c Received block: 0
===================== Channel 'mychannel' created =====================

Having all peers join the channel...
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2020-03-18 08:32:10.827 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-03-18 08:32:10.918 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer0.org1 joined channel 'mychannel' =====================

+ peer channel join -b mychannel.block
+ res=0
+ set +x
2020-03-18 08:32:14.160 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-03-18 08:32:14.247 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer1.org1 joined channel 'mychannel' =====================
+ peer channel join -b mychannel.block

+ res=0
+ set +x
2020-03-18 08:32:17.436 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-03-18 08:32:17.482 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer0.org2 joined channel 'mychannel' =====================

+ peer channel join -b mychannel.block
+ res=0
+ set +x
2020-03-18 08:32:20.665 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-03-18 08:32:20.721 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer1.org2 joined channel 'mychannel' =====================

Updating anchor peers for org1...
+ peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org1MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2020-03-18 08:32:23.897 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-03-18 08:32:23.940 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
===================== Anchor peers updated for org 'Org1MSP' on channel 'mychannel' =====================

Updating anchor peers for org2...
+ peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org2MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2020-03-18 08:32:27.117 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-03-18 08:32:27.159 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
===================== Anchor peers updated for org 'Org2MSP' on channel 'mychannel' =====================

+ peer lifecycle chaincode package mycc.tar.gz --path github.com/hyperledger/fabric-samples/chaincode/abstore/go/ --lang golang --label mycc_1
+ res=0
+ set +x
===================== Chaincode is packaged on peer0.org1 =====================

Installing chaincode on peer0.org1...
+ peer lifecycle chaincode install mycc.tar.gz
+ res=0
+ set +x
2020-03-18 08:33:04.684 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nGmycc_1:2d8de5706ec819943d4a98931bbb377a66b669092ca559a61d0e6721e38af7ca\022\006mycc_1" >
2020-03-18 08:33:04.685 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: mycc_1:2d8de5706ec819943d4a98931bbb377a66b669092ca559a61d0e6721e38af7ca
===================== Chaincode is installed on peer0.org1 =====================

Install chaincode on peer0.org2...
+ peer lifecycle chaincode install mycc.tar.gz
+ res=0
+ set +x
2020-03-18 08:33:27.125 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nGmycc_1:2d8de5706ec819943d4a98931bbb377a66b669092ca559a61d0e6721e38af7ca\022\006mycc_1" >
2020-03-18 08:33:27.125 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: mycc_1:2d8de5706ec819943d4a98931bbb377a66b669092ca559a61d0e6721e38af7ca
===================== Chaincode is installed on peer0.org2 =====================

+ peer lifecycle chaincode queryinstalled
+ res=0
+ set +x
Installed chaincodes on peer:
Package ID: mycc_1:2d8de5706ec819943d4a98931bbb377a66b669092ca559a61d0e6721e38af7ca, Label: mycc_1
PackageID is mycc_1:2d8de5706ec819943d4a98931bbb377a66b669092ca559a61d0e6721e38af7ca
===================== Query installed successful on peer0.org1 on channel =====================

+ peer lifecycle chaincode approveformyorg --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name mycc --version 1 --init-required --package-id mycc_1:2d8de5706ec819943d4a98931bbb377a66b669092ca559a61d0e6721e38af7ca --sequence 1 --waitForEvent
+ set +x
2020-03-18 08:33:27.531 UTC [cli.lifecycle.chaincode] setOrdererClient -> INFO 001 Retrieved channel (mychannel) orderer endpoint: orderer.example.com:7050
2020-03-18 08:33:29.681 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [9224f6b805c828dd052160b3441ec90c9c5990c2819a280a564672a425db9c18] committed with status (VALID) at
===================== Chaincode definition approved on peer0.org1 on channel 'mychannel' =====================

===================== Checking the commit readiness of the chaincode definition on peer0.org1 on channel 'mychannel'... =====================
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1 --sequence 1 --output json --init-required
Attempting to check the commit readiness of the chaincode definition on peer0.org1 ...3 secs
+ res=0
+ set +x

{
	"approvals": {
		"Org1MSP": true,
		"Org2MSP": false
	}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel 'mychannel' =====================
===================== Checking the commit readiness of the chaincode definition on peer0.org2 on channel 'mychannel'... =====================
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1 --sequence 1 --output json --init-required
Attempting to check the commit readiness of the chaincode definition on peer0.org2 ...3 secs
+ res=0
+ set +x

{
	"approvals": {
		"Org1MSP": true,
		"Org2MSP": false
	}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel 'mychannel' =====================
+ peer lifecycle chaincode approveformyorg --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name mycc --version 1 --init-required --package-id mycc_1:2d8de5706ec819943d4a98931bbb377a66b669092ca559a61d0e6721e38af7ca --sequence 1 --waitForEvent
+ set +x
2020-03-18 08:33:36.191 UTC [cli.lifecycle.chaincode] setOrdererClient -> INFO 001 Retrieved channel (mychannel) orderer endpoint: orderer.example.com:7050
2020-03-18 08:33:38.272 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [4997f2f30c647c7362c896e3d88f856e33020ad9229233b138842e6e3506269f] committed with status (VALID) at
===================== Chaincode definition approved on peer0.org2 on channel 'mychannel' =====================

===================== Checking the commit readiness of the chaincode definition on peer0.org1 on channel 'mychannel'... =====================
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1 --sequence 1 --output json --init-required
Attempting to check the commit readiness of the chaincode definition on peer0.org1 ...3 secs
+ res=0
+ set +x

{
	"approvals": {
		"Org1MSP": true,
		"Org2MSP": true
	}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel 'mychannel' =====================
===================== Checking the commit readiness of the chaincode definition on peer0.org2 on channel 'mychannel'... =====================
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1 --sequence 1 --output json --init-required
Attempting to check the commit readiness of the chaincode definition on peer0.org2 ...3 secs
+ res=0
+ set +x

{
	"approvals": {
		"Org1MSP": true,
		"Org2MSP": true
	}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel 'mychannel' =====================
+ peer lifecycle chaincode commit -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name mycc --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --version 1 --sequence 1 --init-required
+ res=0
+ set +x
2020-03-18 08:33:47.436 UTC [chaincodeCmd] ClientWait -> INFO 001 txid [501f9798ad6ae0eaf566114920557c5ac0e793af13f92a8020e65821492ef7ec] committed with status (VALID) at peer0.org2.example.com:9051
2020-03-18 08:33:47.452 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [501f9798ad6ae0eaf566114920557c5ac0e793af13f92a8020e65821492ef7ec] committed with status (VALID) at peer0.org1.example.com:7051
===================== Chaincode definition committed on channel 'mychannel' =====================

===================== Querying chaincode definition on peer0.org1 on channel 'mychannel'... =====================
Attempting to Query committed status on peer0.org1 ...3 secs
+ peer lifecycle chaincode querycommitted --channelID mychannel --name mycc
+ res=0
+ set +x

Committed chaincode definition for chaincode 'mycc' on channel 'mychannel':
Version: 1, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
===================== Query chaincode definition successful on peer0.org1 on channel 'mychannel' =====================
===================== Querying chaincode definition on peer0.org2 on channel 'mychannel'... =====================
+ peer lifecycle chaincode querycommitted --channelID mychannel --name mycc
Attempting to Query committed status on peer0.org2 ...3 secs
+ res=0
+ set +x

Committed chaincode definition for chaincode 'mycc' on channel 'mychannel':
Version: 1, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
===================== Query chaincode definition successful on peer0.org2 on channel 'mychannel' =====================
+ peer chaincode invoke -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --isInit -c '{"Args":["Init","a","100","b","100"]}'
+ res=0
+ set +x
2020-03-18 08:33:54.365 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
===================== Invoke transaction successful on peer0.org1 peer0.org2 on channel 'mychannel' =====================

Querying chaincode on peer0.org1...
===================== Querying on peer0.org1 on channel 'mychannel'... =====================
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
Attempting to Query peer0.org1 ...3 secs
+ res=0
+ set +x

100
===================== Query successful on peer0.org1 on channel 'mychannel' =====================
Sending invoke transaction on peer0.org1 peer0.org2...
+ peer chaincode invoke -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"Args":["invoke","a","b","10"]}'
+ res=0
+ set +x
2020-03-18 08:33:57.957 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
===================== Invoke transaction successful on peer0.org1 peer0.org2 on channel 'mychannel' =====================

Querying chaincode on peer0.org1...
===================== Querying on peer0.org1 on channel 'mychannel'... =====================
Attempting to Query peer0.org1 ...3 secs
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
+ res=0
+ set +x

90
===================== Query successful on peer0.org1 on channel 'mychannel' =====================
Installing chaincode on peer1.org2...
+ peer lifecycle chaincode install mycc.tar.gz
+ res=0
+ set +x
2020-03-18 08:34:19.078 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nGmycc_1:2d8de5706ec819943d4a98931bbb377a66b669092ca559a61d0e6721e38af7ca\022\006mycc_1" >
2020-03-18 08:34:19.078 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: mycc_1:2d8de5706ec819943d4a98931bbb377a66b669092ca559a61d0e6721e38af7ca
===================== Chaincode is installed on peer1.org2 =====================

Querying chaincode on peer1.org2...
===================== Querying on peer1.org2 on channel 'mychannel'... =====================
Attempting to Query peer1.org2 ...3 secs
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
+ res=0
+ set +x

90
===================== Query successful on peer1.org2 on channel 'mychannel' =====================

========= All GOOD, BYFN execution completed ===========


 _____   _   _   ____
| ____| | \ | | |  _ \
|  _|   |  \| | | | | |
| |___  | |\  | | |_| |
|_____| |_| \_| |____/

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据