问题
Here is what I need to do in steps:
- Create a fabric network with 2 orgs: Org1 and Org2.
- Create a channel between them: publicchannel.
- now add an Org3 using steps from this tutorial by fabric: https://hyperledger-fabric.readthedocs.io/en/latest/channel_update_tutorial.html
- Create a new channel: org3org1channel, between org3 and org1.
I'm experiencing problems with step 4, it is returning:
Error: got unexpected status: BAD_REQUEST -- Attempted to include a member which is not in the consortium
when I run:
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
Also, I ensure you all the paths and ENV variables are correct.
Here's my configtx.yaml file:
Organizations:
- &OrdererOrg
Name: OrdererOrg
ID: OrdererMSP
MSPDir: crypto-config/ordererOrganizations/example.com/msp
- &Org1
Name: Org1MSP
ID: Org1MSP
MSPDir: crypto-config/peerOrganizations/org1.example.com/msp
AnchorPeers:
- Host: peer0.org1.example.com
Port: 7051
- &Org2
Name: Org2MSP
ID: Org2MSP
MSPDir: crypto-config/peerOrganizations/bitpay.example.com/msp
AnchorPeers:
- Host: peer0.org2.example.com
Port: 7051
Capabilities:
Global: &ChannelCapabilities
V1_1: true
Orderer: &OrdererCapabilities
V1_1: true
Application: &ApplicationCapabilities
V1_2: true
Application: &ApplicationDefaults
Organizations:
Orderer: &OrdererDefaults
OrdererType: solo
Addresses:
- orderer.example.com:7050
BatchTimeout: 2s
BatchSize:
MaxMessageCount: 10
AbsoluteMaxBytes: 99 MB
PreferredMaxBytes: 512 KB
Kafka:
Brokers:
- 127.0.0.1:9092
Organizations:
Profiles:
ExampleOrdererGenesis:
Capabilities:
<<: *ChannelCapabilities
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Capabilities:
<<: *OrdererCapabilities
Consortiums:
ExampleConsortium:
Organizations:
- *Org1
- *Org2
ExampleChannel:
Consortium: ExampleConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
Capabilities:
<<: *ApplicationCapabilities
TestChannel:
Consortium: ExampleConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org3
Capabilities:
<<: *ApplicationCapabilities
I have created new channels with the new org, using a hack:
- I created 2 orgs as part of the consortium: org1, org2, channelcreatororg.
- I created a new channel named org3org1channel only consisting of org1.
- Now I used https://hyperledger-fabric.readthedocs.io/en/latest/channel_update_tutorial.html to make org3 join org3org1channel.
This works! But I think this is a hack because org1 was already in the genesis block definition of ExampleConsortium
. Suppose I want to add an org4 to this network and create a channel between org4 and org3. it won't be possible. We should be able to update the consortium definition in genesis block to do so.
We should emphesise on the Profile section of the above file:
Profiles:
ExampleOrdererGenesis:
Capabilities:
<<: *ChannelCapabilities
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Capabilities:
<<: *OrdererCapabilities
Consortiums:
ExampleConsortium:
Organizations:
- *Org1
- *Org2
ExampleChannel:
Consortium: ExampleConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
Capabilities:
<<: *ApplicationCapabilities
TestChannel:
Consortium: ExampleConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org3
Capabilities:
<<: *ApplicationCapabilities
I think the problem is that the ExampleOrdererGenesis
contains a consortium definition and it does not include Org3
. Can someone help me with the steps to update it using configtxlator tool?
回答1:
To add new organisation to consortium follow below steps:
$: peer channel fetch config config_block.pb -o orderer.example.com:7050
-c testchainid
$: configtxlator proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config > config.json
$: jq -s '.[0] * {"channel_group":{"groups":{"Consortiums":{"groups": {"TestConsortium": {"groups": {"Org3MSP":.[1]}}}}}}}' config.json ./org3.json > modified_config.json
$: configtxlator proto_encode --input config.json --type common.Config
--output config.pb
$: configtxlator proto_encode --input modified_config.json --type common.Config --output modified_config.pb
$: configtxlator compute_update --channel_id testchainid --original config.pb --updated modified_config.pb --output org_update.pb
$: configtxlator proto_decode --input org_update.pb --type common.ConfigUpdate | jq . > org_update.json
$: echo '{"payload":{"header":{"channel_header":{"channel_id":"testchainid", "type":2}},"data":{"config_update":'$(cat org_update.json)'}}}' | jq . > org_update_in_envelope.json
$: configtxlator proto_encode --input org_update_in_envelope.json --type common.Envelope --output org_update_in_envelope.pb
$: peer channel signconfigtx -f org_update_in_envelope.pb
$: peer channel update -f org_update_in_envelope.pb -c testchainid -o orderer.example.com:7050
回答2:
You have to update this section everytime you add a new org into your consortium:
ExampleOrdererGenesis:
Capabilities:
<<: *ChannelCapabilities
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Capabilities:
<<: *OrdererCapabilities
Consortiums:
ExampleConsortium:
Organizations:
- *Org1
- *Org2
- *Org3
- *Org4
Update this part in your configtx.yaml file then update the configuration using configtxlator tool as given in this tutorial https://hyperledger-fabric.readthedocs.io/en/latest/channel_update_tutorial.html
回答3:
I solved it using this link: https://github.com/rohitadivi/Reconfigure-BYFN/blob/master/Create_channel.md
Make sure you understand what a testchaninid
is within the steps of above link. We create a channel for the orderer, when we fire our genesis block transaction using peer
command. We are fetching that channel and updating it and not any other channel.
来源:https://stackoverflow.com/questions/57144745/cannot-create-channels-with-new-orgs-in-fabric-got-error-attempted-to-include