kalleknast / Microgrid

Hyperledger network for microgrids
GNU General Public License v3.0
4 stars 1 forks source link

Create a channel #1

Closed erickzzh closed 5 years ago

erickzzh commented 5 years ago

I noticed that your channel wont create maybe try running the following code on the order

docker start cli
docker exec -it cli bash
export CHANNEL_NAME={your channel name}
peer channel create -o orderer.{your network name}:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/{your 
 networkname}/orderers/orderer.{your networkname}/msp/tlscacerts/tlsca.acme.com-cert.pem

The peer channel create command returns a genesis block which will be used to join the channel. You can check that by running ls command to review that the file {your channel}.block has been created.

screen shot 2018-09-24 at 12 27 46 pm
erickzzh commented 5 years ago

I think you will also run into the problem of having an invalid channelID as it has to be all lowercase.

https://github.com/hyperledger/fabric/blob/905652065cd10fe21c067cff2f2a760f840f0283/common/configtx/validator.go#L72

kalleknast commented 5 years ago

Thanks!

I changed MicroGridChannel to mg_channel. Entered the cli:

docker exec -it cli bash

and tried to create the channel:

export CHANNEL_NAME=mg_channel
peer channel create -o orderer.microgrid:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/microgrid.org/orderers/orderer.microgrid.org/msp/tlscacerts/tlsca.microgrid.org-cert.pem

But, I still got an error (although another):

2018-09-25 01:03:22.555 UTC [grpc] Printf -> DEBU 03b ClientConn switching balancer to "pick_first"
2018-09-25 01:03:22.555 UTC [grpc] Printf -> DEBU 03c pickfirstBalancer: HandleSubConnStateChange: 0xc4205f6ac0, CONNECTING
2018-09-25 01:03:22.757 UTC [grpc] Printf -> DEBU 03d grpc: addrConn.createTransport failed to connect to {orderer.microgrid:7050 0  <nil>}. Err :connection error: desc = "transport: Error while dialing dial tcp: lookup orderer.microgrid on 127.0.0.11:53: no such host". Reconnecting...
2018-09-25 01:03:22.757 UTC [grpc] Printf -> DEBU 03e pickfirstBalancer: HandleSubConnStateChange: 0xc4205f6ac0, TRANSIENT_FAILURE
2018-09-25 01:03:23.555 UTC [grpc] Printf -> DEBU 03f pickfirstBalancer: HandleSubConnStateChange: 0xc4205f6ac0, CONNECTING
2018-09-25 01:03:23.612 UTC [grpc] Printf -> DEBU 040 grpc: addrConn.createTransport failed to connect to {orderer.microgrid:7050 0  <nil>}. Err :connection error: desc = "transport: Error while dialing dial tcp: lookup orderer.microgrid on 127.0.0.11:53: no such host". Reconnecting...
2018-09-25 01:03:23.613 UTC [grpc] Printf -> DEBU 041 pickfirstBalancer: HandleSubConnStateChange: 0xc4205f6ac0, TRANSIENT_FAILURE
2018-09-25 01:03:24.877 UTC [grpc] Printf -> DEBU 042 pickfirstBalancer: HandleSubConnStateChange: 0xc4205f6ac0, CONNECTING
2018-09-25 01:03:24.916 UTC [grpc] Printf -> DEBU 043 grpc: addrConn.createTransport failed to connect to {orderer.microgrid:7050 0  <nil>}. Err :connection error: desc = "transport: Error while dialing dial tcp: lookup orderer.microgrid on 127.0.0.11:53: no such host". Reconnecting...
2018-09-25 01:03:24.916 UTC [grpc] Printf -> DEBU 044 pickfirstBalancer: HandleSubConnStateChange: 0xc4205f6ac0, TRANSIENT_FAILURE
Error: failed to create deliver client: orderer client failed to connect to orderer.microgrid:7050: failed to create new connection: context deadline exceeded

The issue seems similar to this.

erickzzh commented 5 years ago

yea I had a similar issue like that before

Error: failed to create deliver client: orderer client failed to connect to orderer.microgrid:7050: failed to create new connection: context deadline exceeded

I received the same error msg above and it was caused by a config file setup issue. I will look into your code and try something

erickzzh commented 5 years ago

Channel Name

I am still getting the illegal channel name error I think you can do "mg-channel" but not "mg_channel"

Channel Creation

In order to fix the error below

Error: failed to create deliver client: orderer client failed to connect to orderer.microgrid:7050: failed to create new connection: context deadline exceeded

replace https://github.com/kalleknast/Microgrid/blob/48e6d98fd49774399b34cbcedf2b6f9740cdd46c/base/docker-compose-base.yaml#L12 with

- ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block

make sure that you run the following commands in sequence after you fix the error. This cleans up the old volumes and configs.

docker-compose -f docker-compose-cli.yaml down --volumes
docker-compose -f docker-compose-cli.yaml up -d

I also messed up the channel creation command last night it should've been

export CHANNEL_NAME=mg_channel
peer channel create -o orderer.microgrid.org:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/microgrid.org/orderers/orderer.microgrid.org/msp/tlscacerts/tlsca.microgrid.org-cert.pem

Hopefully, it will work now :)

kalleknast commented 5 years ago

Thanks!! I had to remove all content from crypto-config and channel-artifacts manually. But now, it seems to work. Last lines printed:

2018-09-25 22:06:17.575 UTC [grpc] HandleSubConnStateChange -> DEBU 04b pickfirstBalancer: HandleSubConnStateChange: 0xc4204a78f0, CONNECTING
2018-09-25 22:06:17.577 UTC [grpc] HandleSubConnStateChange -> DEBU 04c pickfirstBalancer: HandleSubConnStateChange: 0xc4204a78f0, READY
2018-09-25 22:06:17.597 UTC [msp] GetDefaultSigningIdentity -> DEBU 04d Obtaining default signing identity
2018-09-25 22:06:17.597 UTC [msp] GetDefaultSigningIdentity -> DEBU 04e Obtaining default signing identity
2018-09-25 22:06:17.597 UTC [msp/identity] Sign -> DEBU 04f Sign: plaintext: 0A84070A1508051A0608D9E2AADD0522...F20BF3EFFB6912080A021A0012021A00 
2018-09-25 22:06:17.597 UTC [msp/identity] Sign -> DEBU 050 Sign: digest: 674461B27C11E87F9BD4A4F2ADD7E0DBE78F86F0B61F8A15CC51028E6CABCC92 
2018-09-25 22:06:17.616 UTC [cli/common] readBlock -> INFO 051 Received block: 0