启动区块链测试网络
./byfn.sh -m up
创建证书使用cryptogen的工具
Generate certificates using cryptogen tool
创造orderer节点的创世区块
Generating Orderer Genesis block
创建channel
Generating channel configuration transaction 'channel.tx'
创建锚节点
Generating anchor peer update for Org1MSP
Generating anchor peer update for Org2MSP
docker启动
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 peer1.org1.example.com ... done
Creating peer0.org2.example.com ... done
Creating orderer.example.com ... done
Creating peer1.org2.example.com ... done
Creating peer0.org1.example.com ... done
Creating cli ... done
org1里面的peer0创建了一个channel
Channel 'mychannel' created
org1的peer0加入了mychannel
peer0.org1 joined channel 'mychannel'
创建锚节点(anchor peer)
用来在不同的组织之间进行数据通信(goosip协议)
Anchor peers updated for org 'Org1MSP' on channel 'mychannel'
Anchor peers updated for org 'Org2MSP' on channel 'mychannel'
安装chaincode
有两台电脑安装了智能合约chaincode
peeer0.org1
peer0.org2
在peer0.org2 上实例化chaincode 背书策略:需要两个人都同意才行
实例化a为100,b为200
Chaincode is instantiated on peer0.org2 on channel 'mychannel'
'{"Args":["init","a","100","b","200"]}'
在org2上实例化的chaincode可以在peer0.org1里面查询出来
查询出a是100
Query successful on peer0.org1 on channel 'mychannel'
'{"Args":["query","a"]}'
在org1组织的peer0执行invoke操作
把a的钱转10块给b
Invoke transaction successful on peer0.org1 peer0.org2 on channel 'mychannel'
'{"Args":["invoke","a","b","10"]}'
最后实例化peer1.org2
查询peer1.org2
查询到a为90
Chaincode is installed on peer1.org2
Querying on peer1.org2 on channel 'mychannel'
Query successful on peer1.org2 on channel 'mychannel'
'{"Args":["query","a"]}'

===================== Channel 'mychannel' created =====================
===================== peer0.org1 joined channel 'mychannel' =====================
===================== peer1.org1 joined channel 'mychannel' =====================
===================== peer0.org2 joined channel 'mychannel' =====================
===================== peer1.org2 joined channel 'mychannel' =====================
===================== Anchor peers updated for org 'Org1MSP' on channel 'mychannel' =====================
===================== Anchor peers updated for org 'Org2MSP' on channel 'mychannel' =====================
===================== Chaincode is installed on peer0.org1 =====================
===================== Chaincode is installed on peer0.org2 =====================
===================== Chaincode is instantiated on peer0.org2 on channel 'mychannel' =====================
===================== Querying on peer0.org1 on channel 'mychannel'... =====================
===================== Query successful on peer0.org1 on channel 'mychannel' =====================
===================== Invoke transaction successful on peer0.org1 peer0.org2 on channel 'mychannel' =====================
===================== Chaincode is installed on peer1.org2 =====================
===================== Querying on peer1.org2 on channel 'mychannel'... =====================
===================== Query successful on peer1.org2 on channel 'mychannel' =====================
[root@Jeter first-network]# ./byfn.sh -m generate
Generating certs and genesis block for channel 'mychannel' with CLI timeout of '10' seconds a' seconds
Continue? [Y/n] y
proceeding ...
/opt/fabric-samples/bin/cryptogen
##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
+ cryptogen generate --config=./crypto-config.yaml
org1.example.com
org2.example.com
+ res=0
+ set +x
Generate CCP files for Org1 and Org2
/opt/fabric-samples/bin/configtxgen
##########################################################
######### Generating Orderer Genesis block ##############
##########################################################
CONSENSUS_TYPE=solo
+ '[' solo == solo ']'
+ configtxgen -profile TwoOrgsOrdererGenesis -channelID byfn-sys-channel -outputBlock ./channis.block
2020-01-10 15:33:54.401 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-01-10 15:33:54.526 CST [common.tools.configtxgen.localconfig] completeInitialization -> ype: solo
2020-01-10 15:33:54.526 CST [common.tools.configtxgen.localconfig] Load -> INFO 003 Loaded cofabric-samples/first-network/configtx.yaml
2020-01-10 15:33:54.642 CST [common.tools.configtxgen.localconfig] completeInitialization -> ype: solo
2020-01-10 15:33:54.642 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 005 Ln: /opt/fabric-samples/first-network/configtx.yaml
2020-01-10 15:33:54.643 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Generating g
2020-01-10 15:33:54.644 CST [common.tools.configtxgen] doOutputBlock -> INFO 007 Writing gene
+ res=0
+ set +x
#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -l
2020-01-10 15:33:54.674 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-01-10 15:33:54.794 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded cofabric-samples/first-network/configtx.yaml
2020-01-10 15:33:54.912 CST [common.tools.configtxgen.localconfig] completeInitialization -> ype: solo
2020-01-10 15:33:54.912 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Ln: /opt/fabric-samples/first-network/configtx.yaml
2020-01-10 15:33:54.912 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 005 Geel configtx
2020-01-10 15:33:54.914 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 006 Wrtx
+ res=0
+ set +x
#################################################################
####### Generating anchor peer update for Org1MSP ##########
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanc mychannel -asOrg Org1MSP
2020-01-10 15:33:54.943 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-01-10 15:33:55.061 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded cofabric-samples/first-network/configtx.yaml
2020-01-10 15:33:55.177 CST [common.tools.configtxgen.localconfig] completeInitialization -> ype: solo
2020-01-10 15:33:55.177 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Ln: /opt/fabric-samples/first-network/configtx.yaml
2020-01-10 15:33:55.177 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 peer update
2020-01-10 15:33:55.177 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 006 r update
+ res=0
+ set +x
#################################################################
####### Generating anchor peer update for Org2MSP ##########
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanc mychannel -asOrg Org2MSP
2020-01-10 15:33:55.207 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-01-10 15:33:55.328 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded cofabric-samples/first-network/configtx.yaml
2020-01-10 15:33:55.442 CST [common.tools.configtxgen.localconfig] completeInitialization -> ype: solo
2020-01-10 15:33:55.442 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Ln: /opt/fabric-samples/first-network/configtx.yaml
2020-01-10 15:33:55.443 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 peer update
2020-01-10 15:33:55.443 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 006 r update
+ res=0
+ set +x
[root@Jeter first-network]# ./byfn.sh -m up
Starting for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] y
proceeding ...
LOCAL_VERSION=1.4.4
DOCKER_IMAGE_VERSION=1.4.4
./byfn.sh: line 175: docker-compose: command not found
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0cc6471438f3 ubuntu "/bin/bash" 46 hours ago Exited (0) 46 hours ago wonderful_spence
770f12eb0622 nginx "nginx -g 'daemon of…" 46 hours ago Up 46 hours 0.0.0.0:8080->80/tcp jovial_elion
66635978982b nginx "-d" 47 hours ago Created 80/tcp silly_grothendieck
e4d64896a00c nginx "-d" 47 hours ago Created 80/tcp hungry_austin
346d413f205b nginx "nginx -g 'daemon of…" 47 hours ago Exited (0) 47 hours ago quirky_chaplygin
d7da8887f422 fce289e99eb9 "/hello" 47 hours ago Exited (0) 47 hours ago inspiring_mcclintock
Error: No such container: cli
ERROR !!!! Test failed
[root@Jeter first-network]# curl -L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 617 0 617 0 0 677 0 --:--:-- --:--:-- --:--:-- 677
100 16.2M 100 16.2M 0 0 791k 0 0:00:21 0:00:21 --:--:-- 3432k
[root@Jeter first-network]# chmod +x /usr/local/bin/docker-compose
[root@Jeter first-network]# ./byfn.sh -m up
Starting for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] y
proceeding ...
LOCAL_VERSION=1.4.4
DOCKER_IMAGE_VERSION=1.4.4
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 peer1.org1.example.com ... done
Creating peer0.org2.example.com ... done
Creating orderer.example.com ... done
Creating peer1.org2.example.com ... done
Creating peer0.org1.example.com ... done
Creating cli ... done
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
786aded66039 hyperledger/fabric-tools:latest "/bin/bash" 1 second ago Up Less than a second cli
cc1905d8f763 hyperledger/fabric-peer:latest "peer node start" 3 seconds ago Up 1 second 0.0.0.0:10051->10051/tcp peer1.org2.example.com
6fae65dc97be hyperledger/fabric-peer:latest "peer node start" 3 seconds ago Up Less than a second 0.0.0.0:9051->9051/tcp peer0.org2.example.com
165acd95b9a4 hyperledger/fabric-peer:latest "peer node start" 3 seconds ago Up Less than a second 0.0.0.0:8051->8051/tcp peer1.org1.example.com
9ec25f411ab8 hyperledger/fabric-orderer:latest "orderer" 3 seconds ago Up 1 second 0.0.0.0:7050->7050/tcp orderer.example.com
303bc3fb9689 hyperledger/fabric-peer:latest "peer node start" 3 seconds ago Up 1 second 0.0.0.0:7051->7051/tcp peer0.org1.example.com
0cc6471438f3 ubuntu "/bin/bash" 47 hours ago Exited (0) 47 hours ago wonderful_spence
770f12eb0622 nginx "nginx -g 'daemon of…" 47 hours ago Up 47 hours 0.0.0.0:8080->80/tcp jovial_elion
66635978982b nginx "-d" 47 hours ago Created 80/tcp silly_grothendieck
e4d64896a00c nginx "-d" 47 hours ago Created 80/tcp hungry_austin
346d413f205b nginx "nginx -g 'daemon of…" 47 hours ago Exited (0) 47 hours ago quirky_chaplygin
d7da8887f422 fce289e99eb9 "/hello" 2 days ago Exited (0) 2 days ago inspiring_mcclintock
____ _____ _ ____ _____
/ ___| |_ _| / \ | _ \ |_ _|
\___ \ | | / _ \ | |_) | | |
___) | | | / ___ \ | _ < | |
|____/ |_| /_/ \_\ |_| \_\ |_|
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-01-10 08:22:53.731 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-01-10 08:22:53.762 UTC [cli.common] readBlock -> INFO 002 Received block: 0
===================== Channel 'mychannel' created =====================
Having all peers join the channel...
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2020-01-10 08:22:53.822 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-01-10 08:22:53.891 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-01-10 08:22:56.951 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-01-10 08:22:56.993 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-01-10 08:23:00.052 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-01-10 08:23:00.094 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-01-10 08:23:03.154 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-01-10 08:23:03.201 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-01-10 08:23:06.261 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-01-10 08:23:06.276 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-01-10 08:23:09.334 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-01-10 08:23:09.347 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
===================== Anchor peers updated for org 'Org2MSP' on channel 'mychannel' =====================
Installing chaincode on peer0.org1...
+ peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
+ res=0
+ set +x
2020-01-10 08:23:12.409 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-01-10 08:23:12.409 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2020-01-10 08:23:13.588 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" >
===================== Chaincode is installed on peer0.org1 =====================
Install chaincode on peer0.org2...
+ peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
+ res=0
+ set +x
2020-01-10 08:23:13.648 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-01-10 08:23:13.649 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2020-01-10 08:23:13.824 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" >
===================== Chaincode is installed on peer0.org2 =====================
Instantiating chaincode on peer0.org2...
+ peer chaincode instantiate -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 -l golang -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P 'AND ('\''Org1MSP.peer'\'','\''Org2MSP.peer'\'')'
+ res=0
+ set +x
2020-01-10 08:23:13.892 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-01-10 08:23:13.892 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
===================== Chaincode is instantiated on 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
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-01-10 08:24:41.918 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
===================== Invoke transaction successful on peer0.org1 peer0.org2 on channel 'mychannel' =====================
Installing chaincode on peer1.org2...
+ peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
+ res=0
+ set +x
2020-01-10 08:24:41.980 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-01-10 08:24:41.981 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2020-01-10 08:24:42.734 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" >
===================== 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 ===========
_____ _ _ ____
| ____| | \ | | | _ \
| _| | \| | | | | |
| |___ | |\ | | |_| |
|_____| |_| \_| |____/
网友评论