Can't deploy transaction to fabric-core - hyperledger

I'm using Vagrant enviroment. I managed to start peer, my chaincode was successfully registered, but when I try to deploy i'm getting the following
vagrant#hyperledger-devenv:v0.2.1-82e72f4:~$
CORE_PEER_ADDRESS=172.17.0.2:7051 peer chaincode deploy -n mytcc -c
'{"Args": ["init", "a","100", "b", "200"]}' - p
github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
Error: Error endorsing chaincode: rpc error: code = 12 desc = unknown
service protos.Endorser
I'm using the following docker-compose.yml file, to launch fabric-peer
vp0:
image: hyperledger/fabric-peer
environment:
- CORE_PEER_ID=vp0
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=http://172.17.0.1:2375
- CORE_LOGGING_LEVEL=DEBUG
command: peer node start --peer-chaincodedev
The fllowing is the command for registering my transaction, and it succeds
CORE_CHAINCODE_ID_NAME=mytcc CORE_PEER_ADDRESS=172.17.0.2:7051 ./chaincode_example02
But then, the following command fails
CORE_PEER_ADDRESS=172.17.0.2:7051 peer chaincode deploy -n mytcc -c '{"Args": ["init", "a","100", "b", "200"]}'
-p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
What is protos.Endorser? Thank you!

Related

CircleCI kubectl config error on deployment to gcloud

I'm new to docker/kubernetes/dev ops in general and I was following a course that used Travis with Github, however I use BitBucket so I'm trying to implement a CI deployment to GKE with CircleCI.
Most of the tasks are working just fine but I'm reaching an error when it comes to kubectl (especifically on the deploy.sh script). Here's the error I'm getting:
unable to recognize "k8s/client-deployment.yml": Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
unable to recognize "k8s/database-persistent-volume-claim.yml": Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
unable to recognize "k8s/ingress-service.yml": Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
unable to recognize "k8s/postgres-cluster-ip-service.yml": Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
unable to recognize "k8s/postgres-deployment.yml": Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
unable to recognize "k8s/redis-cluster-ip-service.yml": Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
unable to recognize "k8s/redis-deployment.yml": Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
unable to recognize "k8s/server-cluster-ip-service.yml": Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
unable to recognize "k8s/server-deployment.yml": Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
unable to recognize "k8s/worker-deployment.yml": Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
I've managed to get this far tackling through problems, however I'm lost on this one so any help is appreciated.
Here's the config.yml for CircleCI (on MyUser I'm actually using my docker user, not an env or anything, it's simply to not disclose it):
version: 2
jobs:
build:
docker:
- image: node
working_directory: ~/app
steps:
- checkout
- setup_remote_docker
- run:
name: Install Docker Client
command: |
set -x
VER="18.09.2"
curl -L -o /tmp/docker-$VER.tgz https://download.docker.com/linux/static/stable/x86_64/docker-$VER.tgz
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
mv /tmp/docker/* /usr/bin
- run:
name: Build Client Docker Image
command: docker build -t MY_USER/multi-docker-react -f ./client/Dockerfile.dev ./client
- run:
name: Run Tests
command: docker run -e CI=true MY_USER/multi-docker-react npm run test -- --coverage
deploy:
working_directory: ~/app
# Docker environment where we gonna run our build deployment scripts
docker:
- image: google/cloud-sdk
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: true
# Set up Env
- run:
name: Setup Environment Variables
command: |
echo 'export GIT_SHA="$CIRCLE_SHA1"' >> $BASH_ENV
echo 'export CLOUDSDK_CORE_DISABLE_PROMPTS=1' >> $BASH_ENV
# Log in to docker CLI
- run:
name: Log in to Docker Hub
command: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_ID" --password-stdin
# !!! This installs gcloud !!!
- run:
name: Installing GCL
working_directory: /
command: |
echo $GCLOUD_SERVICE_KEY | gcloud auth activate-service-account --key-file=-
gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
gcloud --quiet config set compute/zone ${GOOGLE_COMPUTE_ZONE}
# !!! This runs a deployment
- run:
name: Deploying
command: bash ./deploy.sh
workflows:
version: 2
build:
jobs:
- deploy:
filters:
branches:
only:
- master
Here's the deploy.sh:
docker build -t MY_USER/multi-docker-client:latest -t MY_USER/multi-docker-client:$GIT_SHA -f ./client/Dockerfile ./client
docker build -t MY_USER/multi-docker-server:latest -t MY_USER/multi-docker-server:$GIT_SHA -f ./server/Dockerfile ./server
docker build -t MY_USER/multi-docker-worker:latest -t MY_USER/multi-docker-worker:$GIT_SHA -f ./worker/Dockerfile ./worker
docker push MY_USER/multi-docker-client:latest
docker push MY_USER/multi-docker-server:latest
docker push MY_USER/multi-docker-worker:latest
docker push MY_USER/multi-docker-client:$GIT_SHA
docker push MY_USER/multi-docker-server:$GIT_SHA
docker push MY_USER/multi-docker-worker:$GIT_SHA
kubectl apply -f k8s
kubectl set image deployments/client-deployment client=MY_USER/multi-docker-client:$GIT_SHA
kubectl set image deployments/server-deployment server=MY_USER/multi-docker-server:$GIT_SHA
kubectl set image deployments/worker-deployment worker=MY_USER/multi-docker-worker:$GIT_SHA
And here's my project structure:
So turns out I was only missing the next command:
gcloud --quiet container clusters get-credentials multi-cluster
As part of this task:
# !!! This installs gcloud !!!
- run:
name: Installing GCL
working_directory: /
command: |
echo $GCLOUD_SERVICE_KEY | gcloud auth activate-service-account --key-file=-
gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
gcloud --quiet config set compute/zone ${GOOGLE_COMPUTE_ZONE}
gcloud --quiet container clusters get-credentials multi-cluster
Shout out to #DazWilkin for shedding a light

Hyperledger Fabric: Orderer Client failed to connect to orderer.example.com

I am new to hyperledger fabric and I am trying to create a sample blockchain network from scratch using hyperledger fabric. In order to do so, I configured "crypto-config.yaml" file, and generated the respective organization's certificates by running it against the "cryptogen" tool. I also generated the respective "channel-artifacts" by configuring the "configtx.yaml" file and running it against the configtxgen tool. I then modified the "docker-compose-cli.yaml" file and "docker-compose-base" file.
Now, in order to bootstrap the network, I ran the following docker command:
docker-compose -f docker-compose-cli.yaml up
I then executed the following commands:
docker exec -it cli bash
export CHANNEL_NAME=testChannel
peer channel create -o orderer.example.com:7050 -c testChannel -f ./channel-artifacts/testChannel.tx
On executing the "peer channel create" command I received the following error:
Error: failed to create deliver client: orderer client failed to connect to orderer.example.com:7050: failed to create new connection: context deadline exceeded
I am not sure as to why this error is occurring. My configuration for the Address section in OrdererDefaults (in configtx.yaml file) is:
Ordertype:
- solo
Addresses:
- orderer.example.com:7050
Hence, please let me know if I am missing something in order to clear the "peer channel create" issue.
do a docker ps and see if the orderer is up and running
if not do a docker logs orderer.example.com and check orderers logs
usually the orderer logs give clear clues on what has happened
read the logs and fix the issue . that's what i did
and instead of creating a peer first going inside it and creating a channel ,i suggest you create the channel first and join the peer to it afterwards
Create the channel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.tracexyz.com/msp" peer0.org1.tracexyz.com peer channel create -o orderer.tracexyz.com:7050 -c cheeseproduction -f /etc/hyperledger/configtx/channel.tx
Add peer 0 to the channel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.tracexyz.com/msp" peer0.org1.tracexyz.com peer channel join -b cheeseproduction.block
Fetch from peer 1
docker exec -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.tracexyz.com/msp" peer1.org1.tracexyz.com peer channel fetch config -o orderer.tracexyz.com:7050 -c cheeseproduction
Join peer 1 also to the channel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.tracexyz.com/msp" -e "CORE_PEER_ADDRESS=peer1.org1.tracexyz.com:7061" peer0.org1.tracexyz.com peer channel join -b cheeseproduction.block
this is how i connected two peers to a single channel. my org name was tracexyz (tracexyz instead of example ) and my channel name was cheeseproduction
I guesss you can replace those with your own values
after doing these go inside the peer with
docker exec -it cli bash
it will take you inside the default peer which is peer0.org1
then do a peer channel list to see the channels to which peer0 has joined
you will see it will list cheeseproduction

peer chaincode deploy -n mycc -c '{"Args": ["init", "a","100", "b", "200"]}' =>Error connecting to 0.0.0.0:7050 due to grpc: timed out when dialing

I'm doing a project on hyperledger fabric and wish to run the chaincode.
but whenever i run this command
"peer chaincode deploy -n mycc -c '{"Args": ["init", "a","100", "b", "200"]}'"
in my GitBash,
It displayed an error i can't resolve.
"Error: Error getting broadcast client: Error connecting to 0.0.0.0:7050 due to grpc: timed out when dialing"
Is it a port issue?
Can anyone help me resolve this issue?
7050 is the port of orderer service try to verify if you have it using docker images fabric-orderer if not use
docker pull ${DOCKER_NS}/fabric-orderer:${ARCH}-${VERSION}
then use orderer start
in my case :
DOCKER_NS=hyperledger
ARCH=x86_64
VERSION=1.0.0-alpha

HFC: CC deployment successfull while PEER: "Error building images: ..."

TL;DR; Go to ---- EDIT section below
I am using hfc#0.6.5 in a standalone node.js application.
A membersrvc and peer are started with docker-compose, where:
membersrvc:
container_name: membersrvc
image: hyperledger/fabric-membersrvc:latest
ports:
- "7054:7054"
command: membersrvc
vp0:
container_name: peer
image: hyperledger/fabric-peer:latest
ports:
- "7050:7050"
- "7051:7051"
- "7053:7053"
environment:
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_ID=vp0
- CORE_SECURITY_ENABLED=true
- CORE_PEER_PKI_ECA_PADDR=172.17.0.2:7054
- CORE_PEER_PKI_TCA_PADDR=172.17.0.2:7054
- CORE_PEER_PKI_TLSCA_PADDR=172.17.0.2:7054
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=noops
[...]
links:
- membersrvc
command: sh -c "sleep 10; peer node start"
The node.js application successfully registers new users and tries to deploy a chaincode using the enrolledUser.deploy(deployRequest); method.
As a value of deployRequest.chaincodePath a path
'github.com/asset-chaincode/' is set.The directory contains a chaincode .go file.
A callback of deployTx.on('complete', cb) prints its log message:
SUCCESS: Successfully deployed chaincode [chainCodeId:415123c8532fd28393d7a5370193af555e9f2141a4b56e635806e5e1fcce1e58], deploy request={"fcn":"init","args":[],"confidential":true,"metadata":{"type":"Buffer","data":[48,...155,253,0]},"chaincodePath":"github.com/gvlax/chaincodes/asset-chaincode"}, response={"uuid":"415123c8532fd28393d7a5370193af555e9f2141a4b56e635806e5e1fcce1e58","chaincodeID":"415123c8532fd28393d7a5370193af555e9f2141a4b56e635806e5e1fcce1e58"}
chaincodeId=415123c8532fd28393d7a5370193af555e9f2141a4b56e635806e5e1fcce1e58
However, when I check an output of a peer console,
I can see error messages
--> full logs here:
peer | 15:40:00.416 [dockercontroller] deployImage -> ERRO 47a Error building images: The command '/bin/sh -c go install build-chaincode && cp src/build-chaincode/vendor/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin && mv $GOPATH/bin/build-chaincode $GOPATH/bin/23991376d1b935790631a448843fd12a9d60f7ab3f0b8b55f629cf0190077436' returned a non-zero code: 1
[...]
peer | ---> Running in 812439684bf7
peer | src/build-chaincode/asset-chaincode.go:25:2: cannot find package "github.com/hyperledger/fabric/core/chaincode/shim" in any of:
peer | /opt/go/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOROOT)
peer | /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOPATH)
peer | src/build-chaincode/asset-chaincode.go:26:2: cannot find package "github.com/hyperledger/fabric/core/crypto/primitives" in any of:
peer | /opt/go/src/github.com/hyperledger/fabric/core/crypto/primitives (from $GOROOT)
peer | /opt/gopath/src/github.com/hyperledger/fabric/core/crypto/primitives (from $GOPATH)
peer | package build-chaincode
peer | imports github.com/hyperledger/fabric/vendor/github.com/op/go-logging: must be imported as github.com/op/go-logging
[...]
It looks like there are some issues not exactly related to the chaincode compilation on the peer.
Or the chaincode is deployed to a location on the peer where relative import paths in the chaincode cannot be resolved ....
---- EDIT (some hours later)
After many attempts and experiments, I think my problem is always the same:
Regardless of any valid chaincode (stored locally in a directory $GOPATH/src/gibhub.com/<mychaincode_dir> + building with no errors) after being deployed on a peer with the method enrolledUser.deploy(deployRequest) (hfc#0.6.5), a result gives always the same errors on the target node:
peer | Step 4 : RUN go install build-chaincode && cp src/build-chaincode/vendor/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin && mv $GOPATH/bin/build-chaincode $GOPATH/bin/0881d0fe8f4528e1369bfe917cd207d919a07758cc098e212ca74f6766c636d4
peer | ---> Running in b0ca2abbe609
peer | src/build-chaincode/asset-chaincode.go:25:2: cannot find package "github.com/hyperledger/fabric/core/chaincode/shim" in any of:
peer | /opt/gopath/src/build-chaincode/vendor/github.com/hyperledger/fabric/core/chaincode/shim (vendor tree)
peer | /opt/go/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOROOT)
The imports of the cc the peer complains about are:
import (
"encoding/base64"
"errors"
"fmt"
"github.com/hyperledger/fabric/core/chaincode/shim"
[...]
moreover, when I go to the peer CLI, the shim can be found there ...
$ docker exec -it peer bash
$ find / -name shim
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim
$ echo $GOPATH/
/opt/gopath/
Isn't something wrong with the fabric-peer image ???
When you deploy with hfc, you need to "vendor" the fabric chaincode packages - see http://hyperledger-fabric.readthedocs.io/en/v0.6/nodeSDK/node-sdk-indepth/#chaincode-deployment
You can also have a look at https://github.com/IBM-Blockchain/SDK-Demo/tree/master/src/chaincode for an example of doing this with the SDK as well

ERRO : Error trying to connect to local peer: grpc: timed out trying to connect

Unable to deploy chaincode example in my local hyperledger fabric.
system config: mac osx, Docker toolbox for mac
One validating peer is up and running using docker-compose.yaml
membersrvc:
image: hyperledger/fabric-membersrvc
command: membersrvc
vp0:
image: hyperledger/fabric-peer
environment:
- CORE_PEER_ADDRESSAUTODETECT=false
- CORE_VM_ENDPOINT=http://172.17.0.1:2375
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_ID=vp0
- CORE_SECURITY_ENROLLID=test_vp0
- CORE_SECURITY_ENROLLSECRET=MwYpmSRjupbT
links:
- membersrvc
command: sh -c "sleep 5; peer node start --peer-chaincodedev"
While deploying chaincode by running
CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:30303 ./test
Its showing the error as [shim] ERRO : Error trying to connect to local peer: grpc: timed out trying to connect
I tried replacing CORE_PEER_ADDRESS as suggested by grep timeout solution but no change in error.
First Validating peer output
Chaincode deployment error window
You need to use the correct port number on which peer process is listening to.
instead of using the following command,
CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:30303 ./test
try this instead,
CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:7052 ./test
if it doesn't work then run the following command to check your listening port and use that instead,
netstat -atp tcp | grep -i "listen"

Resources