Hyperledger, blockchain explorer launching fails. Can't connect to mychannel - hyperledger-fabric

By using this tutorial i have downloaded fabric's files by this command:
sudo curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/bootstrap.sh| sudo bash -s
I have added sudo because docker commands in my system can only work in that way.
After that, I went to directory fabric-samples/test-network and started fabric:
sudo ./network up
It started successfully. Then I have created channel:
sudo ./network createChannel
Which gave me this result:
Channel 'mychannel' joined
After that I have uploaded chaincode of asset-transfer-basic like this:
sudo ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go
Then I have created separate folder explorer and used these commands:
sudo wget https://raw.githubusercontent.com/hyperledger/blockchain- explorer/main/examples/net1/config.json
sudo wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/examples/net1/connection-profile/test-network.json -P connection-profile
sudo wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/docker-compose.yaml
sudo cp -r ../fabric-samples/test-network/organizations/ .
The docker-compose.yaml was changed into this:
volumes:
- ./config.json:/opt/explorer/app/platform/fabric/config.json
- ./connection-profile:/opt/explorer/app/platform/fabric/connection-profile
- ./organizations:/tmp/crypto
- walletstore:/opt/explorer/wallet
Then on test-network.json I have changed these fields into these:
"adminPrivateKey": {
"path": "/tmp/crypto/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp/keystore/priv_sk"
},
"peers": ["peer0.org1.example.com"],
"signedCert": {
"path": "/tmp/crypto/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp/signcerts/Admin#org1.example.com-cert.pem"
}
After all of this, I launched it by command sudo docker-compose up I get that kind of error in explorer:
[2022-04-21T16:32:34.374] [INFO] FabricConfig - FabricConfig, this.config.channels mychannel
2022-04-21T16:32:34.630Z - error: [DiscoveryService]: send[mychannel] - Channel:mychannel received discovery error:access denied
[2022-04-21T16:32:34.631] [ERROR] FabricClient - Error: DiscoveryService: mychannel error: access denied
at DiscoveryService.send (/opt/explorer/node_modules/fabric-common/lib/DiscoveryService.js:363:11)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async NetworkImpl._initializeInternalChannel (/opt/explorer/node_modules/fabric-network/lib/network.js:279:13)
at async NetworkImpl._initialize (/opt/explorer/node_modules/fabric-network/lib/network.js:231:9)
at async Gateway.getNetwork (/opt/explorer/node_modules/fabric-network/lib/gateway.js:330:9)
Why access denied? Did I miss something?

I'm going to answer for my own question. I hope it will help somebody. The solution of this problem was pretty simple (it's slightly embarrassing)
I needed to set proper volumes in this part:
volumes:
- walletstore:/opt/explorer/wallet
Should be
volumes:
- /path/to/somewhere:/opt/explorer/wallet
It couldn't connect to my channel because it couldn't assign wallet files.

Related

Failed to enroll admin user : Error: Calling enroll endpoint failed with error [Error: socket hang up]

I am facing a problem when I try to run the application in the Hyperledger Fabric 2.3 version.
Reference Link: hyperledger-fabric.readthedocs/test-network/2.3
commands
$ ./network.sh up createChannel
$ ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-javascript/ -ccl javascript
$ node app.js
I successfully create the channel and even deploy the chaincode in javascript, With 2 organizations and 2 peers under each organization and 2 users: admin and user1.
Ubuntu Version: 18.04
Fabric Version: 2.3.x
Can anyone please answer this question?
Looking at your command, an error occurred in the process of enrolling the admin client.
this process is a command that requests enroll from Fabric-CA, and Fabric-CA must be up.
However, in the case of the command ./network.sh up createChannel you entered, Fabric-CA is not up.
You need to add a parameter option to up Fabric-CA.
See the command usage for ./network.sh
https://hyperledger-fabric.readthedocs.io/en/release-2.3/test_network.html
Usage:
network.sh <Mode> [Flags]
Modes:
up - Bring up Fabric orderer and peer nodes. No channel is created
up createChannel - Bring up fabric network with one channel
createChannel - Create and join a channel after the network is created
deployCC - Deploy a chaincode to a channel (defaults to asset-transfer-basic)
down - Bring down the network
Flags:
Used with network.sh up, network.sh createChannel:
-ca <use CAs> - Use Certificate Authorities to generate network crypto material
-c <channel name> - Name of channel to create (defaults to "mychannel")
-s <dbtype> - Peer state database to deploy: goleveldb (default) or couchdb
-r <max retry> - CLI times out after certain number of attempts (defaults to 5)
-d <delay> - CLI delays for a certain number of seconds (defaults to 3)
-i <imagetag> - Docker image tag of Fabric to deploy (defaults to "latest")
-cai <ca_imagetag> - Docker image tag of Fabric CA to deploy (defaults to "latest")
-verbose - Verbose mode
Used with network.sh deployCC
-c <channel name> - Name of channel to deploy chaincode to
-ccn <name> - Chaincode name.
-ccl <language> - Programming language of the chaincode to deploy: go (default), java, javascript, typescript
-ccv <version> - Chaincode version. 1.0 (default), v2, version3.x, etc
-ccs <sequence> - Chaincode definition sequence. Must be an integer, 1 (default), 2, 3, etc
-ccp <path> - File path to the chaincode.
-ccep <policy> - (Optional) Chaincode endorsement policy using signature policy syntax. The default policy requires an endorsement from Org1 and Org2
-cccg <collection-config> - (Optional) File path to private data collections configuration file
-cci <fcn name> - (Optional) Name of chaincode initialization function. When a function is provided, the execution of init will be requested and the function will be invoked.
-h - Print this message
Possible Mode and flag combinations
up -ca -r -d -s -i -cai -verbose
up createChannel -ca -c -r -d -s -i -cai -verbose
createChannel -c -r -d -verbose
deployCC -ccn -ccl -ccv -ccs -ccp -cci -r -d -verbose
Examples:
network.sh up createChannel -ca -c mychannel -s couchdb -i 2.0.0
network.sh createChannel -c channelName
network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-javascript/ -ccl javascript
network.sh deployCC -ccn mychaincode -ccp ./user/mychaincode -ccv 1 -ccl javascript
so, try build a test network with the command below
./network.sh up createChannel -ca

Cannot bring down hyperledger-fabric started sample networks - permission denied

I followed instructions, given in: edx.courses (LinuxFoundationX: LFS171x Blockchain for Business - An Introduction to Hyperledger Technologies),
which is similar to to official guide of hlf (https://hyperledger-fabric.readthedocs.io/en/release-1.1/build_network.html).
Snaped Image: Ubuntu18.04 #VMware Workstation (Host: Win10)
Most interesting parts:
$ curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s 1.1.0
$ export PATH=$PWD/bin:$PATH
$ git clone https://github.com/hyperledger/fabric-samples.git
$ cd fabric-samples/first-network
$ ./byfn.sh -m generate
$ ./byfn.sh -m up
========= All GOOD, BYFN execution completed ===========
_____ _ _ ____
| ____| | \ | | | _ \
| _| | \| | | | | |
| |___ | |\ | | |_| |
|_____| |_| \_| |____/
Now network is up and working. So, let's bring it down without changes:
t1#ubuntu:~/fabric-samples/first-network$ ./byfn.sh -m down
Stopping with channel 'mychannel' and CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n]
proceeding ...
Stopping cli ... error
Stopping peer1.org1.example.com ... error
Stopping peer1.org2.example.com ... error
Stopping peer0.org2.example.com ... error
Stopping peer0.org1.example.com ... error
Stopping orderer.example.com ... error
ERROR: for cli cannot stop container: 743f05760adc094bf402c4d80f76212abe4013e274b4ce5fef49ab40d265431d: Cannot kill container 743f05760adc094bf402c4d80f76212abe4013e274b4ce5fef49ab40d265431d: unknown error after kill: docker-runc did not terminate sucessfully: container_linux.go:387: signaling init process caused "permission denied"
: unknown
Removing network net_byfn
ERROR: error while removing network: network net_byfn id d75ceca2566ded50e7e9a2dce912e54df9b6d243baa8b7e2dade3f72da5d3815 has active endpoints
Stopping cli ... error
Stopping peer1.org1.example.com ... error
Stopping peer1.org2.example.com ... error
Stopping peer0.org2.example.com ... error
Stopping peer0.org1.example.com ... error
Stopping orderer.example.com ... error
ERROR: for cli cannot stop container: 743f05760adc094bf402c4d80f76212abe4013e274b4ce5fef49ab40d265431d: Cannot kill container 743f05760adc094bf402c4d80f76212abe4013e274b4ce5fef49ab40d265431d: unknown error after kill: docker-runc did not terminate sucessfully: container_linux.go:387: signaling init process caused "permission denied"
: unknown
Removing network net_byfn
ERROR: error while removing network: network net_byfn id
Troubleshooting
$ docker rmi -f $(docker images -q)
Will not work:
Deleted: sha256:fd96d34cdd7035e9d7c4fdf4dae4e9c8d4a2e9a5f082a13043bafb5109992a0a
Deleted: sha256:809c70fab2ffe494878efb5afda03b2aaeda26a6113428f1a9a907a800c3bbb7
Deleted: sha256:833649a3e04c96faf218d8082b3533fa0674664f4b361c93cad91cf97222b733
Error response from daemon: conflict: unable to delete be773bfc074c (cannot be forced) - image is being used by running container 546cfd593673
Error response from daemon: conflict: unable to delete 0592b563eec8 (cannot be forced) - image is being used by running container d36402eba8e7
Error response from daemon: conflict: unable to delete 4460ed7ada01 (cannot be forced) - image is being used by running container 6247fdfca8f2
Error: No such image: 72617b4fa9b4
Error response from daemon: conflict: unable to delete b7bfddf508bc (cannot be forced) - image is being used by running container 743f05760adc
Error response from daemon: conflict: unable to delete b7bfddf508bc (cannot be forced) - image is being used by running container 743f05760adc
Error response from daemon: conflict: unable to delete ce0c810df36a (cannot be forced) - image is being used by running container 2314bf8b86b0
Error response from daemon: conflict: unable to delete ce0c810df36a (cannot be forced) - image is being used by running container 2314bf8b86b0
Error response from daemon: conflict: unable to delete b023f9be0771 (cannot be forced) - image is being used by running container 98307e956bd5
Error response from daemon: conflict: unable to delete b023f9be0771 (cannot be forced) - image is being used by running container 541ff05a7925
Error: No such image: 82098abb1a17
Error: No such image: c8b4909d8d46
Error: No such image: 92cbb952b6f8
Error: No such image: 554c591b86a8
Error: No such image: 7e73c828fc5b
Error response from daemon: conflict: unable to delete 220e5cf3fb7f (cannot be forced) - image has dependent child images
Thx for ur support.
(is my first post here, hope it's all fine for your expectation.)
First, deleting the images using docker rmi -f $(docker images -q) won't work, because you have unterminated containers using those images.
The ./byfn.sh -m down script tried to stop the containers spawn by fabriq but there was an error as you can see in the log: signaling init process caused "permission denied": unknown.
The cause of this error is usually AppArmor, try to run:
sudo aa-remove-unknown
and/or to stop the AppArmor service using:
sudo service apparmor stop
sudo update-rc.d -f apparmor remove
Try running below set of command's one by one, it will help you to clean docker containers so you can start fresh
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker volume prune
docker network prune
Note: This wont remove Hyperledger images so no need to worry about reinstalling anything
The same problem in case of Linux Ubuntu:
$sudo systemctl daemon-reload
$sudo systemctl restart docker
$docker ps -qa|xargs docker rm

Hyperledger-composer unable to change BlockTimeout

I am working on prototyping a game using hyperledger-composer. I need to decrease the block time out however the instructions provided in the fabric-dev-servers do not work.
I followed the howtobuild.txt found in ~/fabric-dev-servers/fabric-scripts/hlfv12/composer however installing the network using composer network start --networkName .... the network fails to start with the error:
Error: Error trying to start business network. Error: Failed to connect to any peer event hubs. It is required that at least 1 event hub has been connected to receive the commit event
the versions i am uising are composer#20 and fabric docker images with the tag 1.2.1 (as downloaded by) ./startFabric.sh
The steps I have taken are exactly as follows:
cd ~/fabric-dev-servers/fabric-scripts/hlfv12/composer
nano configtx.yaml
inside this file I
Move the profile block to the bottom of the ymal (to stop the weird error)
change BatchTimeout to 200ms
changed MaxMessageCount to 1
after saving the file I do
rm -r crypto-config
cryptogen generate --config=./crypto-config.yaml
get the new key and update docker-composer.yml and docker-compose-dev.yml
$(ls -1 crypto-config/peerOrganizations/org1.example.com/ca/*_sk`
get key from keystore
ls -1 crypto-config/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp/keystore/*_sk
update peerAdminCard sell script with the new key
nano ../createPeerAdminCard.sh
Generate
configtxgen -profile ComposerChannel -outputCreateChannelTx ./composer-channel.tx -channelID composerchannel`
configtxgen -profile ComposerOrdererGenesis -outputBlock ./composer-genesis.block
create peer admin card
cd ../ && ./createPeerAdminCard.sh
At this point it starts downloading the fabric docker images, which all run successfully
I then create my BNA file and try to start the network
cd /my/buisness/network
composer archive create -t dir -n .
composer network install --card PeerAdmin#hlfv1 --archiveFile my-game#0.0.1.bna
composer network start --networkName my-game --networkVersion 0.0.1 --networkAdmin admin --networkAdminEnrollSecret adminpw --card PeerAdmin#hlfv1 --file networkadmin.card
which gives the error
Error: Error trying to start business network. Error: Failed to connect to any peer event hubs. It is required that at least 1 event hub has been connected to receive the commit event
The Debugging steps i have taken are as follows
After viewing the peer logs i can see delivering blocks to the orderer fails because composerchannel does not exist, so i manually try to create and join the channel manually
docker exec peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c composerchannel -f /etc/hyperledger/configtx/composer-channel.tx
which is a success
2019-03-23 00:07:38.131 UTC [cli/common] readBlock -> INFO 05e Received block: 0
I then try to join the peer to the channel
docker exec peer0.org1.example.com peer channel join -o orderer.example.com:7050 -b composerchannel.block --tls --cafile /etc/hyperledger/msp/users/Admin#org1.example.com/tls/ca.crt --keyfile /etc/hyperledger/msp/users/Admin#org1.example.com/tls/client.key --certfile /etc/hyperledger/msp/users/Admin#org1.example.com/tls/client.crt
which gives the error
proposal failed (err: bad proposal response 500: access denied for [JoinChain][composerchannel]: [Failed verifying that proposal's creator satisfies local MSP principal during channelless check policy with policy [Admins]: [This identity is not an admin]])
There are a lot of different 'Admin' Pems inside the /etc/hyperledger/msp and /etc/hyperledger/tls so I'm pretty much trying all combinations
I'm at a loss, I've been on google for hours trying to find anyone with the same issue but have come up short. Any help will be appreciated.
UPDATE
Turns out explicitly defining the certificates where not needed. running this command allowed me to join the channel.
docker exec peer0.org1.example.com peer channel join -o orderer.example.com:7050 -b composerchannel.block --clientauth --tls
at this point all the docker containers were running and the channel was working. i manage to be able to start the network and everything ran fine (i could request the chaincode, ledger was updating fine etc). However it still seems to take 2 seconds to process a transaction. Again i did some debugging to make sure the config on the order was correct.
fetch config block from channel on orderer
docker exec peer0.org1.example.com peer channel fetch config config_block.pb -o http_s_://orderer.example.com:7050 -c composerchannel --tls --cafile /etc/hyperledger/peer/msp/tlscacerts/tlsca.org1.example.com-cert.pem
copy out of container to local machine
docker cp 5eeaf8c650f8:/root/config_block.pb config_block.pb
convert from proto-buf to json (using configtxlator binary found in fabric-samples)
configtxlator docker exec peer0.org1.example.com proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config > config.json
After getting the config of the channel i could see that the BatchTimeout was 200ms and BatchAmount was 1, yet i still have the 2 seconds timeout per transaction.
While working with Hyperledger composer now you have to keep in mind that it is obselete. I have followed these same steps many times in the past and built custom networks. I think your issue could be of version mismatch. Try downgrading composer to 0.19.
Additionally, did you try doing a docker ps to make sure that all the required containers are running?
Also, before doing the configtxgen command there's a simple command
export FABRIC_CFG_PATH=$PWD
Did you do this?

Unable to run byfn.sh up

I'm trying to run Hyperledger Fabric's byfn on Amazon lightsail instances. I have ran the following launch script:
curl -o lightsail-compose.sh https://raw.githubusercontent.com/KY-Leung/Catena/master/setup/lightsail-compose.sh
chmod +x ./lightsail-compose.sh
./lightsail-compose.sh
curl -o /fabric-setup.sh https://raw.githubusercontent.com/KY-Leung/Catena/master/setup/fabric-setup.sh
chmod +x ./fabric-setup.sh
Subsequently, I SSH-ed into the isntance and executed the follwing:
/fabric-setup.sh
cd fabric-samples/first-network/
./byfn.sh generate
./byfn.sh up
However, the following error occured:
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.0
DOCKER_IMAGE_VERSION=1.4.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 peer1.org2.example.com ...
Creating peer0.org1.example.com ...
Creating orderer.example.com ...
Creating peer1.org1.example.com ...
Creating peer0.org2.example.com ...
./byfn.sh: line 151: 9978 Killed IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE up -d 2>&1
ERROR !!!! Unable to start network
I tried to google but to no avail. Any help is appreciated. Thanks!
Following are the versions:
Docker version 18.09.3, build 774a1f4
docker-compose version 1.23.2, build 1110ad01

Hyperledger Fabric chaincode instantiation error

I'm using fabric tools provided for composer to deploy fabric network as it deploys 1 peer, 1 orderer, 1 couchdb, & 1 fabric-ca. I am able to install chain code on peer but instantiation fails with following error. I am using command on fabric-peer.
peer chaincode instantiate -o orderer.example.com:7050 -C composerchannel -n test -l node -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}'
Error: could not assemble transaction, err Proposal response was not
successful, error code 500, msg failed to execute transaction
83b806a14ec33d47e11950581357cc0ab05ef51dfb53d35c6b9f00eca7a49051:
timeout expired while starting chaincode test:1.0 for transaction
83b806a14ec33d47e11950581357cc0ab05ef51dfb53d35c6b9f00eca7a49051
And if I check the logs of orderer I get:
2018-09-01 11:09:16.205 UTC [orderer/common/broadcast] Handle -> WARN
973 Error reading from 172.19.0.14:33674: rpc error: code = Canceled
desc = context canceled
in my case (windows 10) I stopped the network, removed all containers then restarted, worked fine:
$ docker stop $(docker ps -a -q)
$ docker ps -qa|xargs docker rm
$ ./startFabric.sh
Check logs on node (VM) which host peer0 with:
docker ps -a
you will find chaincode container ID with exit code.
CONTAINER ID: **718e367bf1db**
IMAGE: dev-peer1-org1-**mycc-0.2**-9c1906
COMMAND: "/bin/sh -c 'cd /usr…"
where mycc-0.2 is you chaincode name and version. Once you find the container ID - you can check the error log with:
docker logs <container_id>
I assume there is a bug in the your chaincode and the application can't start.

Resources