Cannot create channels with new orgs in Fabric, got error: Attempted to include a member which is not in the consortium
Cannot create channels with new orgs in Fabric, got error: Attempted to include a member which is not in the consortium
以下是我需要按步骤执行的操作:
- 使用 2 个组织创建结构网络:Org1 和 Org2。
- 在他们之间创建一个频道:publicchannel。
- 现在使用 fabric 本教程中的步骤添加 Org3:https://hyperledger-fabric.readthedocs.io/en/latest/channel_update_tutorial.html
- 在 org3 和 org1 之间创建一个新频道:org3org1channel。
我在执行第 4 步时遇到问题,它正在返回:
Error: got unexpected status: BAD_REQUEST -- Attempted to include a member which is not in the consortium
当我 运行:
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
此外,我确保您所有的路径和 ENV 变量都是正确的。
这是我的 configtx.yaml 文件:
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
我使用 hack 在新组织中创建了新频道:
- 我创建了 2 个组织作为联盟的一部分:org1、org2、channelcreatororg。
- 我创建了一个名为 org3org1channel 的新频道,仅由 org1 组成。
- 现在我用https://hyperledger-fabric.readthedocs.io/en/latest/channel_update_tutorial.html让org3加入org3org1channel。
这有效!但我认为这是一个 hack,因为 org1 已经在 ExampleConsortium
的创世块定义中。假设我想向这个网络添加一个 org4 并在 org4 和 org3 之间创建一个通道。这是不可能的。为此,我们应该能够更新创世块中的联盟定义。
我们应该强调上述文件的配置文件部分:
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
我认为问题在于 ExampleOrdererGenesis
包含联盟定义,但不包含 Org3
。有人可以帮助我完成使用 configtxlator 工具更新它的步骤吗?
每次将新组织添加到联盟中时都必须更新此部分:
ExampleOrdererGenesis:
Capabilities:
<<: *ChannelCapabilities
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Capabilities:
<<: *OrdererCapabilities
Consortiums:
ExampleConsortium:
Organizations:
- *Org1
- *Org2
- *Org3
- *Org4
在您的 configtx.yaml 文件中更新此部分,然后使用本教程中提供的 configtxlator 工具更新配置 https://hyperledger-fabric.readthedocs.io/en/latest/channel_update_tutorial.html
要将新组织添加到联盟,请按照以下步骤操作:
$: 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
我用这个 link 解决了它:https://github.com/rohitadivi/Reconfigure-BYFN/blob/master/Create_channel.md
确保您了解上述 link 中的 testchaninid
是什么。当我们使用 peer
命令启动我们的创世块交易时,我们为排序者创建了一个通道。我们正在获取并更新该频道,而不是任何其他频道。
以下是我需要按步骤执行的操作:
- 使用 2 个组织创建结构网络:Org1 和 Org2。
- 在他们之间创建一个频道:publicchannel。
- 现在使用 fabric 本教程中的步骤添加 Org3:https://hyperledger-fabric.readthedocs.io/en/latest/channel_update_tutorial.html
- 在 org3 和 org1 之间创建一个新频道:org3org1channel。
我在执行第 4 步时遇到问题,它正在返回:
Error: got unexpected status: BAD_REQUEST -- Attempted to include a member which is not in the consortium
当我 运行:
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
此外,我确保您所有的路径和 ENV 变量都是正确的。
这是我的 configtx.yaml 文件:
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
我使用 hack 在新组织中创建了新频道:
- 我创建了 2 个组织作为联盟的一部分:org1、org2、channelcreatororg。
- 我创建了一个名为 org3org1channel 的新频道,仅由 org1 组成。
- 现在我用https://hyperledger-fabric.readthedocs.io/en/latest/channel_update_tutorial.html让org3加入org3org1channel。
这有效!但我认为这是一个 hack,因为 org1 已经在 ExampleConsortium
的创世块定义中。假设我想向这个网络添加一个 org4 并在 org4 和 org3 之间创建一个通道。这是不可能的。为此,我们应该能够更新创世块中的联盟定义。
我们应该强调上述文件的配置文件部分:
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
我认为问题在于 ExampleOrdererGenesis
包含联盟定义,但不包含 Org3
。有人可以帮助我完成使用 configtxlator 工具更新它的步骤吗?
每次将新组织添加到联盟中时都必须更新此部分:
ExampleOrdererGenesis:
Capabilities:
<<: *ChannelCapabilities
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Capabilities:
<<: *OrdererCapabilities
Consortiums:
ExampleConsortium:
Organizations:
- *Org1
- *Org2
- *Org3
- *Org4
在您的 configtx.yaml 文件中更新此部分,然后使用本教程中提供的 configtxlator 工具更新配置 https://hyperledger-fabric.readthedocs.io/en/latest/channel_update_tutorial.html
要将新组织添加到联盟,请按照以下步骤操作:
$: 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
我用这个 link 解决了它:https://github.com/rohitadivi/Reconfigure-BYFN/blob/master/Create_channel.md
确保您了解上述 link 中的 testchaninid
是什么。当我们使用 peer
命令启动我们的创世块交易时,我们为排序者创建了一个通道。我们正在获取并更新该频道,而不是任何其他频道。