Hyperledger, create a channel using the configtxgen CLI tool - hyperledger-fabric

I am following https://hyperledger-fabric.readthedocs.io/en/release-2.1/create_channel/create_channel.html tutorial.
first of all, i didnt find TwoOrgsChannel in profile in configtx.yaml in my version, so i added this section to the profile and got it work and successes in creating a channel creation transaction for channel1.
but the command after that which will create the channel using peer channel create, return an error that i searched for but didnt get any similar post, which is:
Endorser and orderer connections initialized
Error: got unexpected status: BAD_REQUEST -- channel creation request not allowed because the orderer system channel is not defined
the section i had added to profile is:
TwoOrgsChannel:
Consortium: SampleConsortium
<<: *ChannelDefaults
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
Capabilities:
<<: *ApplicationCapabilities

Have you created Orderer profile in your configtx.yaml ?
Ordered system channel is required for order and peer for channel initialization.
Refer this link for configtx.yaml
https://medium.com/#msakhilvinayak/understanding-configurations-in-hyperledger-fabric-ff3f5c23625a

Related

How to have a consortium with 1 organization in a network with two organizations?

I am setting up a server composed of two organizations (3 later), as shown in the following link : https://hyperledger-fabric.readthedocs.io/en/release-1.4/network/network.html
However, the consortium must not contain the two organizations (Org1 and Org2) but only organization 1 (Org1) as shown in this image: https://imgur.com/a/gcBcINq
In my configtx.yaml file, I set the SampleConsortium value as a follow:
Profiles:
TwoOrgsOrdererGenesis:
<<: *ChannelDefaults
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Capabilities:
<<: *OrdererCapabilities
Consortiums:
SampleConsortium:
Organizations:
- *Org1
# - *Org2
TwoOrgsChannel:
Consortium: SampleConsortium
<<: *ChannelDefaults
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
Capabilities:
<<: *ApplicationCapabilities
So I define a consortium with a single organization: Org2.
However, when instantiating my channel with the line of code
peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f./channel-artifacts/channel.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example. com-cert.pem
The screen displays an error telling me: Error: got unexpected status: BAD_REQUEST -- Attempted to include a member which is not in the consortium
Do you have an idea to generate my channel by having only one organization in my consortium?
Thank you very much in advance for your answers :)
PS : This is my first project with hyperledger fabric, so I am still "new" with this technology. However, it seems to me that there is no indication that a consortium should not have at least 2 organizations.
You have to comment Org2 from TwoOrgsChannel profile. then you will be able to create my channel once this is done you can add Org2 by updating the channel config for further details you can refer read the docs https://hyperledger-fabric.readthedocs.io/en/release-1.4/channel_update_tutorial.html
Thank you very much, your solution worked. However, I can only add the Org1 Organization in my channel. If I comment on the Org2 line, an error
Error: got unexpected status: BAD_REQUEST -- error validating channel creation transaction for new channel 'mychannel', could not succesfully apply update to template configuration: error authorizing update: error validating DeltaSet: policy for [Group] /Channel/Application not satisfied: implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the 'Admins' sub-policies to be satisfied
While my configtx.yaml file looks like this:
Profiles:
TwoOrgsOrdererGenesis:
<<: *ChannelDefaults
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Capabilities:
<<: *OrdererCapabilities
Consortiums:
SampleConsortium:
Organizations:
- *Org1
- *Org2
TwoOrgsChannel:
Consortium: SampleConsortium
<<: *ChannelDefaults
Application:
<<: *ApplicationDefaults
Organizations:
# - *Org1
- *Org2
Capabilities:
<<: *ApplicationCapabilities

Hyperledger fabric 1.2 capabilities error

I am trying to use hyperledger fabric sample network with my own chaincode.
I am using balance-transfer but my chaincode requires collections config file because It is using private data. I added to sendInstantiateProposal request but, I keep getting the error while instantiating the chaincode;
{"success":false,"message":"Failed to instantiate the chaincode. cause:instantiate proposal resulted in an error :: Error: as V1_2 or later capability is not enabled, private channel collections and data are not available"}
I added capabilities section to artifacts/channel/configtx.yaml file but error still continue. You can see that file from this link.
So, how can I solve this error and make this network work with private channels ?
This error occurs when Application and channels are not enabled with the V1.2 or above capabilities.
Solution:
Add Capabilities in configtx.yaml file
Capabilities:
# Channel capabilities apply to both the orderers and the peers and must be
# supported by both.
# Set the value of the capability to true to require it.
Channel: &ChannelCapabilities
# V1.3 for Channel is a catchall flag for behavior which has been
# determined to be desired for all orderers and peers running at the v1.3.x
# level, but which would be incompatible with orderers and peers from
# prior releases.
# Prior to enabling V1.3 channel capabilities, ensure that all
# orderers and peers on a channel are at v1.3.0 or later.
V1_3: true
# Orderer capabilities apply only to the orderers, and may be safely
# used with prior release peers.
# Set the value of the capability to true to require it.
Orderer: &OrdererCapabilities
# V1.1 for Orderer is a catchall flag for behavior which has been
# determined to be desired for all orderers running at the v1.1.x
# level, but which would be incompatible with orderers from prior releases.
# Prior to enabling V1.1 orderer capabilities, ensure that all
# orderers on a channel are at v1.1.0 or later.
V1_1: true
# Application capabilities apply only to the peer network, and may be safely
# used with prior release orderers.
# Set the value of the capability to true to require it.
Application: &ApplicationCapabilities
# V1.3 for Application enables the new non-backwards compatible
# features and fixes of fabric v1.3.
V1_3: true
V1_2: false
V1_1: false
And then apply them in Profile section
ThreeOrgsOrdererGenesis:
<<: *ChannelDefaults
Capabilities:
<<: *ChannelCapabilities
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Capabilities:
<<: *OrdererCapabilities
Consortiums:
SampleConsortium:
Organizations:
- *Org1
- *Org2
- *Org3
ThreeOrgsChannel:
Consortium: SampleConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
- *Org3
Capabilities:
<<: *ApplicationCapabilities
Refer fabric-samples/first-network configtx.yaml file for more details.

Error when installing channel: "Error: got unexpected status: BAD_REQUEST -- Unknown consortium name: SampleConsortium"

When I try to install a channel it gives me the following error:
Error: got unexpected status: BAD_REQUEST -- Unknown consortium name: SampleConsortium
On the orderer I get the following WARN:
Rejecting broadcast of config message from 172.18.0.3:57490 because of error:Unknown consortium name: SampleConsortium
I am not referencing sample consortium In any way, I cant find it In any of the generated channel artifacts and on the logs of, peer, orderer, and cli does not appear any other feedback.
I am using version 1.4
I will be happy to share more info.
EDIT1:
I see something weird when using the command create on the cli I get the following feedback:
[common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /etc/hyperledger/fabric/configtx.yaml
And when seeing that config Is a default template of the configtx file. Why is it doing this?
The consortium is defined in the file called configtx.yaml (specifically in the Profile section) , this is the file is used to create orderer genesis block and is embedded in docker-compose yaml file in orderer config section.
When you do docker-compose up this block is hardcoded into the orderer along with a system channel called testchainid. To verify the same, look up the docker logs by docker logs -f <orderer.example.com or whatever the url is>.
Looks like you have misconfigured configtx file, refer this file for better reference.
Specifically, You probably wrote something like
Profiles:
mychannel:
Consortium: SampleConsortium
Application:
...
And missed defining the SampleConsortium in the genesis profile like
Profile:
TwoOrgGenesis:
Consortiums:
SampleConsortium:
Organizations:
- <<: *org1
Policies:
....
After making required modifications in the configtx file, recreate the artifacts including genesis.block, channel.tx, anchors.tx before restarting the network.

Hyperledger configtxgen creates genesis.block without Application Group

Whenever I try to connect a peer to a channel I receive the following error message :
Error: proposal failed (err: rpc error: code = Unknown desc = chaincode error (status: 500, message: "JoinChain" for chainID = productionChannel failed because of validation of configuration block, because of Invalid configuration block, missing Application configuration group))
I’ve noticed that when I have done the example setups, the genesis block has a section for Application. However, with my current setup, the genesis block does not contain the Application section. Is there a way to instantiate the genesis block with the application embedded or another way to join the peer to the channel?
My configtx.yaml is below :
Profiles:
OneOrgOrdererGenesis:
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Consortiums:
SampleConsortium:
Organizations:
- *TestOrg
OneOrgChannel:
Consortium: SampleConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *TestOrg
Organizations:
- &OrdererOrg
Name: OrdererMSP
ID: OrdererMSP
MSPDir: crypto-config/ordererOrganizations/test-com/msp
- &TestOrg
Name: TestOrgMSP
ID: TestOrgMSP
MSPDir: crypto-config/peerOrganizations/testorg-test-com/msp
AnchorPeers:
- Host: peer0-testorg-test-com
Port: 7051
Orderer: &OrdererDefaults
OrdererType: solo
Addresses:
- orderer-test-com:7050
BatchTimeout: 2s
BatchSize:
MaxMessageCount: 10
AbsoluteMaxBytes: 99 MB
PreferredMaxBytes: 512 KB
Kafka:
Brokers:
- 127.0.0.1:9092
Organizations:
Application: &ApplicationDefaults
Organizations:
If any one else runs into this issue, here is what is happening.
I was mistakenly trying to join the peers to the genesis block. The genesis block should not have an application section in it, as it is the system channel. This is created either through using the configtxgen tool from Fabric, or having the Orderer produce it when it is first created.
Then you need to create another channel block, using configtxgen or through CLI peer channel create . Then you can issue a peer channel join command using the -b flag for the path of the block.

Error: got unexpected status: FORBIDDEN -- Failed to reach implicit threshold of 1 sub-policies, required 1 remaining: permission denied

My fabric version is 1.1.0-preview, the peer, orderer, configtxgen is newly generated.
when I execute the configtxgen tool:
configtxgen -profile SoloOrdererGenesis -outputBlock genesis.block
configtxgen -profile mych -outputCreateChannelTx channel-artifacts/mych.tx -channelID mych
It generate the genesis.block and mych.tx with channelName is mych.
Then orderer start with genesis.block, I execute following:
peer channel create -f mych.tx -o orderer.example.com:7050 -c mych
it throw the error,
Error: got unexpected status: FORBIDDEN -- Failed to reach implicit threshold of 1 sub-policies, required 1 remaining: permission denied
which step is wrong?
my configtx.yaml file is:
---
Profiles:
SoloOrdererGenesis:
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Consortiums:
SampleConsortium4:
Organizations:
- *Org1
- *Org2
- *Org3
- *Org4
SampleConsortium3:
Organizations:
- *Org1
- *Org2
- *Org3
SampleConsortium2:
Organizations:
- *Org1
- *Org2
SampleConsortium1:
Organizations:
- *Org1
mych4:
Consortium: SampleConsortium4
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
- *Org3
- *Org4
mych3:
Consortium: SampleConsortium3
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
- *Org3
mych2:
Consortium: SampleConsortium2
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
mych1:
Consortium: SampleConsortium1
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
Organizations:
- &OrdererOrg
Name: OrdererOrg
ID: OrdererMSP
MSPDir: orderer/msp
- &Org1
Name: Org1MSP
ID: Org1MSP
MSPDir: org1/peer/msp
AnchorPeers:
- Host: peer.org1.example.com
Port: 17051
- &Org2
Name: Org2MSP
ID: Org2MSP
MSPDir: org2/peer/msp
AnchorPeers:
- Host: peer.org2.example.com
Port: 27051
Orderer: &OrdererDefaults
OrdererType: solo
Addresses:
- orderer.example.com:7050
BatchTimeout: 2s
BatchSize:
MaxMessageCount: 10
AbsoluteMaxBytes: 99 MB
PreferredMaxBytes: 512 KB
Organizations:
Application: &ApplicationDefaults
Organizations:
When I got this problem my solutions was pretty simple .. I had already started my network using
/byfn.sh -m up
forgot about it and was trying to start it first by generating the crypto and then using the same command.
The problem was resolved as soon as I first downed the old network using
/byfn.sh -m down
and started again with the same up command.
It could very well be a simple matter of the wrong path for a file. When you generated the mych.tx file, you wrote it to channel-artifacts/mych.tx but when try to create the channel, you left out the channel-artifacts directory. You could try peer channel create -f channel-artifacts/mych.tx -o orderer.example.com:7050 -c mych
That said, I just had a similar problem with the same error. I was testing a newly created genesis block and crypto. In my case, it was the result of the previous crypto and channel being stored in a Docker volume from one of my previous tests. That may not be the case with you, since you said you are creating a new peer and orderer.
You can check on that by connecting to one of the peers (or cli container if you have one) with docker exec -it <container name> bash and then running peer channel list. If you get something like this back, then that's your problem:
root#4cf873123669:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer channel list
2018-04-05 14:09:40.734 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-04-05 14:09:40.734 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-04-05 14:09:40.739 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-04-05 14:09:40.740 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0AAE070A5C08031A0C08A4DC98D60510...631A0D0A0B4765744368616E6E656C73
2018-04-05 14:09:40.740 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 93EFB49DD86ABB5568DE1E2C8FC53FA99AB52929AFA24D7B317C270DE8CDC80B
Channels peers has joined:
mych
2018-04-05 14:09:40.743 UTC [main] main -> INFO 006 Exiting.....
If you don't see the mych listed under "Channels peers has joined:", then my answer is not pertinent to you. (But may be to someone else!)
Here is how you would restore your local Hyperledger Docker instance to a clean state:
docker-compose -f docker-compose.yaml down --volumes
The --volumes tells Docker to remove any volumes associated with the containers in the configuration file.
For good measure, I just wiped everything (all Docker containers and volumes - this was a test system) down to a blank slate and started the process all over:
docker-compose -f docker-compose.yaml down --volumes
docker rm $(docker ps -aq)
docker volume prune
rm genesis.block channel-artifacts/mych.tx
Once I removed those, and started the Fabric back up, I was able to create the channel without getting that error.
If it doesn't work last resort will be sudo service docker restart which will restart all the docker services like docker system, network and volumes.
configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-
artifacts/genesis.block -channelID $CHANNEL_NAME
while creating the genesis block you need pass the syschannelname.
while creating channel use the different channel name.
Eg:
1.sysmych
2.mych
It would be clearer if you share the debug log of orderer. To enable debug add
- ORDERER_GENERAL_LOGLEVEL=debug
in your docker compose file under orderer service, and start your network again. you can then print out the log using command
docker logs CONTAINER_NAME --details
I suggest to print the log before and after running the create channel command.
I had the same Error got resolved as below
you may need to add
Go path also
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
echo $GOPATH
followed by /byfn.sh -m down if it is Up Earlier.
reference:
https://hyperledger-fabric.readthedocs.io/en/release-1.1/prereqs.html
If any of the solutions on this page didn't work out for anyone then try removing your network from docker networks. View your docker networks by running docker network ls and remove your network by running docker network rm <network-name>.
Removing docker network worked out for me but I did this on a dev server.
In my case the problem was with the permission as well as network already being up( partially).
I had started with "./byfn.sh up" without using sudo , so i got error for first time.
Next, i did "sudo su" then ran "./byfn up", again i got error.
Referring to one of the answers here being a superuser i did "./byfn down" and then "./byfn up" now, this worked for me.
I encounter this issue many times, always use docker volume prune to solve it.

Resources