Hyperledger Fabric2.3 环境搭建及Fabric 测试网络使用
一、安装ubuntu20
Download Ubuntu Desktop | Download | Ubuntu
二、安装环境
参考:
Prerequisites — hyperledger-fabricdocs main documentation
3、文件下载和配置
https://github.com/hyperledger/fabric/tree/v2.3.0
进入scripts,执行bootstrap.sh
在命令行输入:sudo ./bootstrap.sh
因为网络的问题,经常会下载出错,这个时候我们多执行几次,如果你没有耐心了,你可以这样做:我们对执行这个文件进行分析,无非就是下载了三个部分:
1.fabric的二进制文件
2.fabric-samples文件夹
3.fabric的镜像文件
我们可以这样:
首先,sudo ./bootstrap.sh -b 这个意思是仅仅拉去fabric的镜像文件:
执行完毕后可以发现:
然后,下载fabric-samples,
GitHub - hyperledger/fabric-samples at v2.3.0
放进scrips文件内部。
最后,下载二进制文件
https://github.com/hyperledger/fabric/releases/tag/v2.3.0
项目结构如下:
cp * /usr/local/bin/
4、测试
-
切换到test-network目录测试网络
cd fabric-samples/test-network
-
在目录中,运行以下命令以从任何以前的运行中删除任何容器或项目:
test-network
./network.sh down
然后,您可以通过发出以下命令来启动网络
./network.sh up
生成容器
1、创建通道
./network.sh createChannel
出现以上代码,则表示成功
2、在通道上启动链码,部署链码
./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go
正常情况下是运行报错的。
链码路径,没有vendor文件夹(go语言依赖包)。
所以要 运行
go mod vendor
这个需要翻墙,也报错先执行下面代码,为go语言源换一个境内源。
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct
然后执行 go mod vendor
最后执行部署链码命令
./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go
出现以上代码,则成功。
3、添加机构1的环境变量
(test-network)目录下执行
export PATH=${PWD}/../bin:$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
4、使用资产初始化分类帐
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --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":"InitLedger","Args":[]}'
peer chaincode query -C mychannel -n basic -c '{"Args":["GetAllAssets"]}'
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --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":"TransferAsset","Args":["asset6","Christopher"]}'
如果成功,您应该看到类似于以下内容的输出:
5、添加机构2的环境变量
使机构2可以与链码交互
# Environment variables for Org2
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID="Org2MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
export CORE_PEER_ADDRESS=localhost:9051
您现在可以查询,在上运行的资产转移(基本)链码
peer chaincode query -C mychannel -n basic -c '{"Args":["ReadAsset","asset6"]}'
结果如下:
6、关闭网络
./network.sh down
博主运行代码如下,仅供参考。
hanlw@ubuntu:~/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network$ sudo su root
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
aadb837df673 hyperledger/fabric-tools:latest "/bin/bash" 15 minutes ago Up 15 minutes cli
c4434566b601 hyperledger/fabric-orderer:latest "orderer" 15 minutes ago Up 15 minutes 0.0.0.0:7050->7050/tcp, :::7050->7050/tcp, 0.0.0.0:7053->7053/tcp, :::7053->7053/tcp orderer.example.com
36ba6d8f081a hyperledger/fabric-peer:latest "peer node start" 15 minutes ago Up 15 minutes 7051/tcp, 0.0.0.0:9051->9051/tcp, :::9051->9051/tcp peer0.org2.example.com
88e6f142ed46 hyperledger/fabric-peer:latest "peer node start" 15 minutes ago Up 15 minutes 0.0.0.0:7051->7051/tcp, :::7051->7051/tcp peer0.org1.example.comroot@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# docker -v
Docker version 20.10.12, build e91ed57
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# docker-compose -v
docker-compose version 1.25.0, build unknown
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# go version
go version go1.15.2 linux/amd64
hanlw@ubuntu:~/go/src/hyperleger$ cd fabric-2.3.0/
hanlw@ubuntu:~/go/src/hyperleger/fabric-2.3.0$ ls
bccsp cmd config docker-env.mk go.sum integration Makefile pkg sampleconfig tox.ini
bin CODE_OF_CONDUCT.md CONTRIBUTING.md docs gotools.mk internal msp protoutil scripts vagrant
CHANGELOG.md CODEOWNERS core go.mod idemix LICENSE NOTICE README.md SECURITY.md vendor
ci common discovery gossip images MAINTAINERS.md orderer release_notes tools
hanlw@ubuntu:~/go/src/hyperleger/fabric-2.3.0$ cd scripts/
hanlw@ubuntu:~/go/src/hyperleger/fabric-2.3.0/scripts$ cd fabric-samples/hanlw@ubuntu:~/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples$ ls
asset-transfer-abac asset-transfer-sbe CHANGELOG.md config LICENSE SECURITY.md
asset-transfer-basic asset-transfer-secured-agreement ci CONTRIBUTING.md MAINTAINERS.md test-application
asset-transfer-events auction CODE_OF_CONDUCT.md fabcar off_chain_data test-network
asset-transfer-ledger-queries bin CODEOWNERS high-throughput README.md token-erc-20
asset-transfer-private-data chaincode commercial-paper interest_rate_swaps scripts token-utxo
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hyperledger/fabric-tools 2.3 2172e1e8ef5a 14 months ago 438MB
hyperledger/fabric-tools 2.3.0 2172e1e8ef5a 14 months ago 438MB
hyperledger/fabric-tools latest 2172e1e8ef5a 14 months ago 438MB
hyperledger/fabric-peer 2.3 a572d898402a 14 months ago 56MB
hyperledger/fabric-peer 2.3.0 a572d898402a 14 months ago 56MB
hyperledger/fabric-peer latest a572d898402a 14 months ago 56MB
hyperledger/fabric-orderer 2.3 0a77c2792890 14 months ago 39.2MB
hyperledger/fabric-orderer 2.3.0 0a77c2792890 14 months ago 39.2MB
hyperledger/fabric-orderer latest 0a77c2792890 14 months ago 39.2MB
hyperledger/fabric-ccenv 2.3 9432940881da 14 months ago 502MB
hyperledger/fabric-ccenv 2.3.0 9432940881da 14 months ago 502MB
hyperledger/fabric-ccenv latest 9432940881da 14 months ago 502MB
hyperledger/fabric-baseos 2.3 4dbd6846872b 14 months ago 6.39MB
hyperledger/fabric-baseos 2.3.0 4dbd6846872b 14 months ago 6.39MB
hyperledger/fabric-baseos latest 4dbd6846872b 14 months ago 6.39MB
hyperledger/fabric-ca 1.4 dbbc768aec79 15 months ago 158MB
hyperledger/fabric-ca 1.4.9 dbbc768aec79 15 months ago 158MB
hyperledger/fabric-ca latest dbbc768aec79 15 months ago 158MB
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# ./network.sh down
Stopping network
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.
No containers available for deletion
No images available for deletion
Unable to find image 'busybox:latest' locally
latest: Pulling from library/busybox
5cc84ad355aa: Pull complete
Digest: sha256:5acba83a746c7608ed544dc1533b87c737a0b0fb730301639a0179f9344b1678
Status: Downloaded newer image for busybox:latestroot@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# ./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.3.0
DOCKER_IMAGE_VERSION=2.3.0
/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/../bin/cryptogen
Generating certificates using cryptogen tool
Creating Org1 Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output=organizations
org1.example.com
+ res=0
Creating Org2 Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output=organizations
org2.example.com
+ res=0
Creating Orderer Org Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output=organizations
+ res=0
Generating CCP files for Org1 and Org2
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.org1.example.com ... done
Creating peer0.org2.example.com ... done
Creating orderer.example.com ... done
Creating cli ... doneroot@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# ./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 genesis block 'mychannel.block'
/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/../bin/configtxgen
+ configtxgen -profile TwoOrgsApplicationGenesis -outputBlock ./channel-artifacts/mychannel.block -channelID mychannel
2022-01-18 19:54:54.278 PST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2022-01-18 19:54:54.283 PST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: etcdraft
2022-01-18 19:54:54.283 PST [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
2022-01-18 19:54:54.283 PST [common.tools.configtxgen.localconfig] Load -> INFO 004 Loaded configuration: /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/configtx/configtx.yaml
2022-01-18 19:54:54.284 PST [common.tools.configtxgen] doOutputBlock -> INFO 005 Generating genesis block
2022-01-18 19:54:54.284 PST [common.tools.configtxgen] doOutputBlock -> INFO 006 Creating application channel genesis block
2022-01-18 19:54:54.284 PST [common.tools.configtxgen] doOutputBlock -> INFO 007 Writing genesis block
+ res=0
Creating channel mychannel
Using organization 1
+ osnadmin channel join --channel-id mychannel --config-block ./channel-artifacts/mychannel.block -o localhost:7053 --ca-file /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --client-cert /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt --client-key /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.key
+ res=0
Status: 201
{
"name": "mychannel",
"url": "/participation/v1/channels/mychannel",
"consensusRelation": "consenter",
"status": "active",
"height": 1
}Channel 'mychannel' created
Joining org1 peer to the channel...
Using organization 1
+ peer channel join -b ./channel-artifacts/mychannel.block
+ res=0
2022-01-18 19:55:00.450 PST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2022-01-18 19:55:00.470 PST [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
Joining org2 peer to the channel...
Using organization 2
+ peer channel join -b ./channel-artifacts/mychannel.block
+ res=0
2022-01-18 19:55:03.535 PST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2022-01-18 19:55:03.562 PST [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
Setting anchor peer for org1...
Using organization 1
Fetching channel config for channel mychannel
Using organization 1
Fetching the most recent configuration block for the channel
+ peer channel fetch config config_block.pb -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c mychannel --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
2022-01-19 03:55:03.750 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2022-01-19 03:55:03.753 UTC [cli.common] readBlock -> INFO 002 Received block: 0
2022-01-19 03:55:03.753 UTC [channelCmd] fetch -> INFO 003 Retrieving last config block: 0
2022-01-19 03:55:03.755 UTC [cli.common] readBlock -> INFO 004 Received block: 0
Decoding config block to JSON and isolating config to Org1MSPconfig.json
+ configtxlator proto_decode --input config_block.pb --type common.Block
+ jq '.data.data[0].payload.data.config'
Generating anchor peer update transaction for Org1 on channel mychannel
+ jq '.channel_group.groups.Application.groups.Org1MSP.values += {"AnchorPeers":{"mod_policy": "Admins","value":{"anchor_peers": [{"host": "peer0.org1.example.com","port": 7051}]},"version": "0"}}' Org1MSPconfig.json
+ configtxlator proto_encode --input Org1MSPconfig.json --type common.Config
+ configtxlator proto_encode --input Org1MSPmodified_config.json --type common.Config
+ configtxlator compute_update --channel_id mychannel --original original_config.pb --updated modified_config.pb
+ configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate
+ jq .
++ cat config_update.json
+ echo '{"payload":{"header":{"channel_header":{"channel_id":"mychannel", "type":2}},"data":{"config_update":{' '"channel_id":' '"mychannel",' '"isolated_data":' '{},' '"read_set":' '{' '"groups":' '{' '"Application":' '{' '"groups":' '{' '"Org1MSP":' '{' '"groups":' '{},' '"mod_policy":' '"",' '"policies":' '{' '"Admins":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Endorsement":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Readers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Writers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '}' '},' '"values":' '{' '"MSP":' '{' '"mod_policy":' '"",' '"value":' null, '"version":' '"0"' '}' '},' '"version":' '"0"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '},' '"write_set":' '{' '"groups":' '{' '"Application":' '{' '"groups":' '{' '"Org1MSP":' '{' '"groups":' '{},' '"mod_policy":' '"Admins",' '"policies":' '{' '"Admins":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Endorsement":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Readers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Writers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '}' '},' '"values":' '{' '"AnchorPeers":' '{' '"mod_policy":' '"Admins",' '"value":' '{' '"anchor_peers":' '[' '{' '"host":' '"peer0.org1.example.com",' '"port":' 7051 '}' ']' '},' '"version":' '"0"' '},' '"MSP":' '{' '"mod_policy":' '"",' '"value":' null, '"version":' '"0"' '}' '},' '"version":' '"1"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '}' '}}}}'
+ configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope
2022-01-19 03:55:04.017 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2022-01-19 03:55:04.042 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
Anchor peer set for org 'Org1MSP' on channel 'mychannel'
Setting anchor peer for org2...
Using organization 2
Fetching channel config for channel mychannel
Using organization 2
Fetching the most recent configuration block for the channel
+ peer channel fetch config config_block.pb -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c mychannel --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
2022-01-19 03:55:04.243 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2022-01-19 03:55:04.246 UTC [cli.common] readBlock -> INFO 002 Received block: 1
2022-01-19 03:55:04.247 UTC [channelCmd] fetch -> INFO 003 Retrieving last config block: 1
2022-01-19 03:55:04.249 UTC [cli.common] readBlock -> INFO 004 Received block: 1
Decoding config block to JSON and isolating config to Org2MSPconfig.json
+ configtxlator proto_decode --input config_block.pb --type common.Block
+ jq '.data.data[0].payload.data.config'
+ jq '.channel_group.groups.Application.groups.Org2MSP.values += {"AnchorPeers":{"mod_policy": "Admins","value":{"anchor_peers": [{"host": "peer0.org2.example.com","port": 9051}]},"version": "0"}}' Org2MSPconfig.json
Generating anchor peer update transaction for Org2 on channel mychannel
+ configtxlator proto_encode --input Org2MSPconfig.json --type common.Config
+ configtxlator proto_encode --input Org2MSPmodified_config.json --type common.Config
+ configtxlator compute_update --channel_id mychannel --original original_config.pb --updated modified_config.pb
+ configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate
+ jq .
++ cat config_update.json
+ echo '{"payload":{"header":{"channel_header":{"channel_id":"mychannel", "type":2}},"data":{"config_update":{' '"channel_id":' '"mychannel",' '"isolated_data":' '{},' '"read_set":' '{' '"groups":' '{' '"Application":' '{' '"groups":' '{' '"Org2MSP":' '{' '"groups":' '{},' '"mod_policy":' '"",' '"policies":' '{' '"Admins":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Endorsement":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Readers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Writers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '}' '},' '"values":' '{' '"MSP":' '{' '"mod_policy":' '"",' '"value":' null, '"version":' '"0"' '}' '},' '"version":' '"0"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '},' '"write_set":' '{' '"groups":' '{' '"Application":' '{' '"groups":' '{' '"Org2MSP":' '{' '"groups":' '{},' '"mod_policy":' '"Admins",' '"policies":' '{' '"Admins":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Endorsement":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Readers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '},' '"Writers":' '{' '"mod_policy":' '"",' '"policy":' null, '"version":' '"0"' '}' '},' '"values":' '{' '"AnchorPeers":' '{' '"mod_policy":' '"Admins",' '"value":' '{' '"anchor_peers":' '[' '{' '"host":' '"peer0.org2.example.com",' '"port":' 9051 '}' ']' '},' '"version":' '"0"' '},' '"MSP":' '{' '"mod_policy":' '"",' '"value":' null, '"version":' '"0"' '}' '},' '"version":' '"1"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '}' '},' '"mod_policy":' '"",' '"policies":' '{},' '"values":' '{},' '"version":' '"0"' '}' '}}}}'
+ configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope
2022-01-19 03:55:04.507 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2022-01-19 03:55:04.524 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
Anchor peer set for org 'Org2MSP' on channel 'mychannel'
Channel 'mychannel' joined
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go
deploying chaincode on channel 'mychannel'
executing with the following
- CHANNEL_NAME: mychannel
- CC_NAME: basic
- CC_SRC_PATH: ../asset-transfer-basic/chaincode-go
- CC_SRC_LANGUAGE: go
- CC_VERSION: 1.0
- CC_SEQUENCE: 1
- CC_END_POLICY: NA
- CC_COLL_CONFIG: NA
- CC_INIT_FCN: NA
- DELAY: 3
- MAX_RETRY: 5
- VERBOSE: false
Vendoring Go dependencies at ../asset-transfer-basic/chaincode-go
/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/asset-transfer-basic/chaincode-go /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network
go: github.com/golang/protobuf@v1.3.2: Get "https://proxy.golang.org/github.com/golang/protobuf/@v/v1.3.2.mod": dial tcp 142.251.43.17:443: i/o timeout
/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network
Finished vendoring Go dependencies
+ peer lifecycle chaincode package basic.tar.gz --path ../asset-transfer-basic/chaincode-go --lang golang --label basic_1.0
+ res=0
Chaincode is packaged
Installing chaincode on peer0.org1...
Using organization 1
+ peer lifecycle chaincode install basic.tar.gz
+ res=0
2022-01-18 19:56:23.181 PST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nJbasic_1.0:4ec191e793b27e953ff2ede5a8bcc63152cecb1e4c3f301a26e22692c61967ad\022\tbasic_1.0" >
2022-01-18 19:56:23.181 PST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: basic_1.0:4ec191e793b27e953ff2ede5a8bcc63152cecb1e4c3f301a26e22692c61967ad
Chaincode is installed on peer0.org1
Install chaincode on peer0.org2...
Using organization 2
+ peer lifecycle chaincode install basic.tar.gz
+ res=0
2022-01-18 19:56:33.076 PST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nJbasic_1.0:4ec191e793b27e953ff2ede5a8bcc63152cecb1e4c3f301a26e22692c61967ad\022\tbasic_1.0" >
2022-01-18 19:56:33.076 PST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: basic_1.0:4ec191e793b27e953ff2ede5a8bcc63152cecb1e4c3f301a26e22692c61967ad
Chaincode is installed on peer0.org2
Using organization 1
+ peer lifecycle chaincode queryinstalled
+ res=0
Installed chaincodes on peer:
Package ID: basic_1.0:4ec191e793b27e953ff2ede5a8bcc63152cecb1e4c3f301a26e22692c61967ad, Label: basic_1.0
Query installed successful on peer0.org1 on channel
Using organization 1
+ peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name basic --version 1.0 --package-id basic_1.0:4ec191e793b27e953ff2ede5a8bcc63152cecb1e4c3f301a26e22692c61967ad --sequence 1
+ res=0
2022-01-18 19:56:35.256 PST [chaincodeCmd] ClientWait -> INFO 001 txid [3b9fbc1703895142f114bf999c9eea025e72998634562b5f48c67408ec3df4c1] committed with status (VALID) at localhost:7051
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, Retry after 3 seconds.
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 1.0 --sequence 1 --output json
+ res=0
{
"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, Retry after 3 seconds.
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 1.0 --sequence 1 --output json
+ res=0
{
"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 --cafile /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name basic --version 1.0 --package-id basic_1.0:4ec191e793b27e953ff2ede5a8bcc63152cecb1e4c3f301a26e22692c61967ad --sequence 1
+ res=0
2022-01-18 19:56:43.556 PST [chaincodeCmd] ClientWait -> INFO 001 txid [3fb5559603c11bd5b2564c4275ece248518bef1cefba1f9b72a11954f0788652] committed with status (VALID) at localhost:9051
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, Retry after 3 seconds.
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 1.0 --sequence 1 --output json
+ res=0
{
"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, Retry after 3 seconds.
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 1.0 --sequence 1 --output json
+ res=0
{
"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 --cafile /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name basic --peerAddresses localhost:7051 --tlsRootCertFiles /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles /home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --version 1.0 --sequence 1
+ res=0
2022-01-18 19:56:51.992 PST [chaincodeCmd] ClientWait -> INFO 001 txid [1ba67fae47f0174aa971a7ee43bd7af0bbe1cd16f55ef8daee5722230d4cf518] committed with status (VALID) at localhost:7051
2022-01-18 19:56:52.015 PST [chaincodeCmd] ClientWait -> INFO 002 txid [1ba67fae47f0174aa971a7ee43bd7af0bbe1cd16f55ef8daee5722230d4cf518] 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 basic
+ res=0
Committed chaincode definition for chaincode 'basic' on channel 'mychannel':
Version: 1.0, 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 basic
+ res=0
Committed chaincode definition for chaincode 'basic' on channel 'mychannel':
Version: 1.0, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
Query chaincode definition successful on peer0.org2 on channel 'mychannel'
Chaincode initialization is not requiredroot@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export PATH=${PWD}/../bin:$PATH
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export FABRIC_CFG_PATH=$PWD/../config/
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_TLS_ENABLED=true
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_LOCALMSPID="Org1MSP"
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_ADDRESS=localhost:7051
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --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":"InitLedger","Args":[]}'
2022-01-18 20:41:44.848 PST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# peer chaincode query -C mychannel -n basic -c '{"Args":["GetAllAssets"]}'
[{"ID":"asset1","color":"blue","size":5,"owner":"Tomoko","appraisedValue":300},{"ID":"asset2","color":"red","size":5,"owner":"Brad","appraisedValue":400},{"ID":"asset3","color":"green","size":10,"owner":"Jin Soo","appraisedValue":500},{"ID":"asset4","color":"yellow","size":10,"owner":"Max","appraisedValue":600},{"ID":"asset5","color":"black","size":15,"owner":"Adriana","appraisedValue":700},{"ID":"asset6","color":"white","size":15,"owner":"Michel","appraisedValue":800}]root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --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":"TransferAsset","Args":["asset6","Christopher"]}'
2022-01-18 20:45:22.523 PST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# peer chaincode query -C mychannel -n basic -c '{"Args":["GetAllAssets"]}'
[{"ID":"asset1","color":"blue","size":5,"owner":"Tomoko","appraisedValue":300},{"ID":"asset2","color":"red","size":5,"owner":"Brad","appraisedValue":400},{"ID":"asset3","color":"green","size":10,"owner":"Jin Soo","appraisedValue":500},{"ID":"asset4","color":"yellow","size":10,"owner":"Max","appraisedValue":600},{"ID":"asset5","color":"black","size":15,"owner":"Adriana","appraisedValue":700},{"ID":"asset6","color":"white","size":15,"owner":"Christopher","appraisedValue":800}]
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_TLS_ENABLED=true
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_LOCALMSPID="Org2MSP"
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# export CORE_PEER_ADDRESS=localhost:9051root@ubuntu:/home/hanlw/go/src/hyperleger/fabric-2.3.0/scripts/fabric-samples/test-network# peer chaincode query -C mychannel -n basic -c '{"Args":["ReadAsset","asset6"]}'
{"ID":"asset6","color":"white","size":15,"owner":"Christopher","appraisedValue":800}
参考:
关于fabric中执行./bootstrap.sh之后出错的解决方案_lakersssss24的博客-CSDN博客
更多推荐
所有评论(0)