New RAFT orderer cannot detect that it belongs to an application channel - hyperledger-fabric

I have an initial Hyperledger Fabric network as the following:
org1.example.com has 2 RAFT nodes. The system channel name is system-channel (there is only 1 consortium defined). The application channel name is channel1 in which the peer from org1.example.com runs chaincode1. Note that there is no separate orderer organization.
The system channel profile is:
OrdererGenesis:
<<: *ChannelDefaults
Orderer:
<<: *OrdererDefaults
Organizations:
- *Org1
Consortiums:
SampleConsortium:
Organizations:
- *Org1
I want to add another organization, org2.example.com so that the final network will be:
Steps that I took for system-channel (I followed https://hyperledger-fabric.readthedocs.io/en/release-1.4/raft_configuration.html#reconfiguration):
Add Org2MSP definition to Orderer Channel Group in system-channel
Add Org2MSP definition to Consortium Channel Group in system-channel
Add Org2's orderer information (tls certs, etc) to the consenters list i.e. channel_group.groups.Orderer.values.ConsensusType.value.metadata.consenters in system-channel
Start Org2's orderer i.e. orderer0.org2.example.com
Add orderer0.org2.example.com to the list of orderer addresses in system-channel i.e. .channel_group.values.OrdererAddresses.value.addresses
All the above steps work well and orderer0.org2.example.com serves system-channel
Moving on, the steps that I took for channel1:
Add Org2MSP definition to Orderer Channel Group in channel1
Add Org2MSP definition to Application Channel Group in channel1
Add orderer0.org2.example.com to the list of orderer addresses in channel1 i.e. .channel_group.values.OrdererAddresses.value.addresses
Add orderer0.org2.example.com's information (tls certs, etc) to the consenters list i.e. channel_group.groups.Orderer.values.ConsensusType.value.metadata.consenters in channel1
Up to step number 3, everything is OK. Once I completed step 4, I begin to see channel1 does not exist errors the following in the newly added orderer orderer0.org2.example.com:
2019-05-09 09:38:03.360 UTC [comm.grpc.server] 1 -> INFO 05a streaming call completed grpc.service=orderer.Cluster grpc.method=Step grpc.peer_address=192.168.224.6:43116 grpc.peer_subject="CN=orderer0.org1.example.com,OU=peer+OU=org1,O=org1.example.com,L=Singapore,ST=Singapore,C=SG" error="channel channel1 doesn't exist" grpc.code=Unknown grpc.call_duration=711.5µs
In the current RAFT leader, there are error messages as well (3 refers to orderer0.org2.example.com:
2019-05-09 09:38:02.859 UTC [orderer.consensus.etcdraft] logSendFailure -> ERRO 0c5 Failed to send StepRequest to 3, because: aborted channel=channel1 node=1
It seems that orderer0.org2.example.com is not aware that it is supposed to serve channel1. I also cannot see channel1 folder in /var/hyperledger/production/orderer/chains in orderer0.org2.example.com
As part of my troubleshooting, I tried to persist all the orderers' /var/hyperledger/production/orderer folder which contains the chain. shut down orderer0.org1.example.com and orderer0.org2.example.com and copy the channel1 folder from orderer0.org1.example.com to orderer0.org2.example.com and finally start both orderers.
Now orderer0.org2.example.com knows that it needs to serve channel1 as evidenced in the logs
2019-05-10 02:36:04.161 UTC [orderer.consensus.etcdraft] apply -> INFO 044 Applied config change to add node 1, current nodes in channel: [1] channel=channel1 node=3
2019-05-10 02:36:04.161 UTC [orderer.consensus.etcdraft] apply -> INFO 045 Applied config change to add node 2, current nodes in channel: [1 2] channel=channel1 node=3
2019-05-10 02:36:04.161 UTC [orderer.consensus.etcdraft] writeBlock -> INFO 046 Got block [6], expect block [7], this node was forced to catch up channel=channel1 node=3
2019-05-10 02:36:04.161 UTC [orderer.consensus.etcdraft] apply -> INFO 047 Applied config change to add node 3, current nodes in channel: [1 2 3] channel=channel1 node=3
Based on above, it is obvious orderer0.org2.example,com has no way to receive channel1's block to start serving the channel. For peers, peer can receive the block and issue peer channel join block_name.block but orderers can't do that. I am wondering what step am I missing.
To simulate the environment and reproduce the issue, refer to: https://github.com/aldredb/bring-your-own-orderer

This is resolved. The issue is that I didn't use the latest config block as the bootstrap block in the new orderer, orderer0.org2.example.com. Once I did the aforementioned, orderer0.org2.example.com is able to detect channel1:
2019-05-10 14:06:04.778 UTC [orderer.common.server] replicateDisabledChains -> INFO 072 Successfully replicated 0 chains: []
2019-05-10 14:06:44.680 UTC [orderer.common.server] replicateDisabledChains -> INFO 073 Found 1 inactive chains: [channel1]
2019-05-10 14:06:44.689 UTC [orderer.common.cluster] ReplicateChains -> INFO 074 Will now replicate chains [channel1]

Related

Error: can't read the block: &{NOT_FOUND}

After adding an organization to the channel I am unable to get block 0 it says:
2021-01-05 10:30:48.412 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-05 10:30:48.500 UTC [cli.common] readBlock -> INFO 002 Expect block, but got status: &{NOT_FOUND} Error: can't read the block: &{NOT_FOUND}
Any idea how to resolve this?
I am using v2.3 for the orderer and peers, and I am able to fetch the block with the other organization's peer.
You could try this:
Ran startup.sh, so that recreated the channel allarewelcome (and deleted all the existing peer containers)
For both the peer definitions in docker-compose.yml file, i changed image: hyperledger/fabric-peer to image: hyperledger/fabric-peer:1.4.4
After starting the peer containers, i was able to fetch the genesis block for allarewelcome channel, as also able to join it.

Unable to update channel config using Fabric SDK Java: field "common.ConfigUpdate.channel_id" contains invalid UTF-8

Network setup:
The network is setup with 1 orderer + 2 organizations with 2 peers each (2 * 2 = 4 peers).
I don't think there's a problem with the network, nor with the crypto materials, the channel config transactions, since I've done similar things using Fabric SDK Go without going into this kind of problem.
What I have done:
The error occurs after I created the channel "mychannel", added two peers of the client org to the channel, initialized the channel using Fabric SDK Java and then tried to update the channel.
Before I tried to invoke channel.updateChannelConfiguration() to apply the config tx file Org1MSPanchors.tx, I managed to get the signatures from the admins of both the orgs.
The key lines (the project is written in Kotlin, the following is the Java equivalent):
var updateConfig = new UpdateChannelConfiguration(new File("path/to/file.tx"));
// The signatures have been created from the admins of the 2 orgs.
channel.updateChannelConfiguration(updateConfig, signatures);
Logs:
After the invocation, the program crashed with the following info.
Caused by: org.hyperledger.fabric.sdk.exception.TransactionException: Channel mychannel, send transaction failed on orderer OrdererClient{id: 4, channel: mychannel, name: orderer.***.com, url: grpcs://localhost:7050}. Reason: Channel mychannel orderer orderer.***.com status returned failure code 400 (BAD_REQUEST) during orderer next
at org.hyperledger.fabric.sdk.OrdererClient.sendTransaction(OrdererClient.java:240) ~[fabric-sdk-java-1.4.13.jar:na]
at org.hyperledger.fabric.sdk.Orderer.sendTransaction(Orderer.java:164) ~[fabric-sdk-java-1.4.13.jar:na]
at org.hyperledger.fabric.sdk.Channel.sendUpdateChannel(Channel.java:549) ~[fabric-sdk-java-1.4.13.jar:na]
at org.hyperledger.fabric.sdk.Channel.updateChannelConfiguration(Channel.java:455) ~[fabric-sdk-java-1.4.13.jar:na]
at org.hyperledger.fabric.sdk.Channel.updateChannelConfiguration(Channel.java:412) ~[fabric-sdk-java-1.4.13.jar:na]
at com.***.util.SDKUtil$Companion.updateChannel(SDKUtil.kt:68) ~[main/:na]
at com.***.***Application.configureChannel(FjstApplication.kt:76) ~[main/:na]
at com.***.***Application.access$configureChannel(FjstApplication.kt:19) ~[main/:na]
at com.***.***Application$commandLineRunner$2.run(FjstApplication.kt:54) ~[main/:na]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:804) [spring-boot-2.4.0.jar:2.4.0]
... 5 common frames omitted
Caused by: org.hyperledger.fabric.sdk.exception.TransactionException: Channel mychannel orderer orderer.***.com status returned failure code 400 (BAD_REQUEST) during orderer next
at org.hyperledger.fabric.sdk.OrdererClient$1.onNext(OrdererClient.java:186) ~[fabric-sdk-java-1.4.13.jar:na]
And the docker logs of orderer.***.com:
2020-12-14 09:14:48.443 UTC [orderer.commmon.multichannel] newChain -> INFO 00b Created and starting new chain mychannel
2020-12-14 09:14:48.451 UTC [comm.grpc.server] 1 -> INFO 00c streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=192.168.128.1:35988 grpc.code=OK grpc.call_duration=60.307408ms
2020-12-14 09:15:01.201 UTC [comm.grpc.server] 1 -> INFO 00d streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=192.168.128.1:35988 grpc.code=OK grpc.call_duration=1.770753ms
2020-12-14 09:15:01.208 UTC [orderer.common.broadcast] ProcessMessage -> WARN 00e [channel: mychannel] Rejecting broadcast of config message from 192.168.128.1:35988 because of error: error applying config update to existing channel 'mychannel': error authorizing update: proto: field "common.ConfigUpdate.channel_id" contains invalid UTF-8
2020-12-14 09:15:01.208 UTC [comm.grpc.server] 1 -> INFO 00f streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Broadcast grpc.peer_address=192.168.128.1:35988 grpc.code=OK grpc.call_duration=349.969µs
The config and network files:
https://1drv.ms/u/s!Aj_rPvkyS8y8gtsXEaKBXD1riM12CQ?e=jkMeYn
Please help:
If a solution is not obvious, could you please tell me what the possible causes are?
Thanks!

Error loading MSP configuration for org Org1MSP

I am facing a problem while creating the channel in HyperLedger Fabric Blockchain
ubuntu#Raghav:/mnt/c/fabric-samples/test-network$ ./network.sh createChannel
Creating channel 'mychannel'.
If network is not up, starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb
Generating channel create transaction 'mychannel.tx'
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/mychannel.tx -channelID mychannel
The logs are the following ones:
2020-10-17 12:16:23.571 IST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-10-17 12:16:23.651 IST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /mnt/c/fabric-samples/test-network/configtx/configtx.yaml
2020-10-17 12:16:23.651 IST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 003 Generating new channel configtx
2020-10-17 12:16:23.668 IST [common.tools.configtxgen] main -> FATA 004 Error on outputChannelCreateTx: could not generate default config template: error parsing configuration: could not create application group: failed to create application org: 1 - Error loading MSP configuration for org Org1MSP: could not load a valid ca certificate from directory /mnt/c/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/msp/cacerts: stat /mnt/c/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/msp/cacerts: no such file or directory
+ res=1
Failed to generate channel configuration transaction...
Create channel failed

failed constructing descriptor for chaincodes

I am trying to do a transaction from the user but when I am trying to get the channel then I am getting this error:
Microservice Logs:
error: [DiscoveryService]: send[mychannel] - Channel:mychannel received discovery error:failed constructing descriptor for chaincodes:<name:"mychannel" >
createTransaction Error: Cannot do transaction in blockchain: DiscoveryService: mychannel error: failed constructing descriptor for chaincodes:<name:"mychannel" >
at FabricRepository.<anonymous> (/app/microservice/dist/services/blockchain-client.js:235:23)
at Generator.throw (<anonymous>)
at rejected (/app/microservice/dist/services/blockchain-client.js:6:65)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
POST /fabric-service/createTransaction 997.103
Peer Logs:
2020-10-20 20:23:54.218 UTC [discovery.endorsement] func1 -> DEBU d98 Endpoint: peer0.org2.com:7052, InternalEndpoint: , PKI-ID: 82f87b1ae00364c30ce6293dd804af5f81462b137b8e4d151580b9fcafa9b4c9, Metadata: satisfies principal principal:"\n\013Org2MSP\020\003"
2020-10-20 20:23:54.218 UTC [discovery.endorsement] func1 -> DEBU d99 Endpoint: peer0.org2.com:7052, InternalEndpoint: , PKI-ID: 82f87b1ae00364c30ce6293dd804af5f81462b137b8e4d151580b9fcafa9b4c9, Metadata: doesn't satisfy principal principal:"\n\007Org2MSP\020\003" : the identity is a member of a different MSP (expected Org1MSP, got Org2MSP)
2020-10-20 20:23:54.218 UTC [discovery] chaincodeQuery -> ERRO d9a Failed constructing descriptor for chaincode chaincodes:<name:"mychannel" > ,: no peer combination can satisfy the endorsement policy
Configtx:
mychannel:
Consortium: MyConsortium
<<: *ChannelDefaults
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
Capabilities:
<<: *ApplicationCapabilities
Overall if I am doing the same transaction from org1 Peer I am getting similar error at the peer both are failing. If I remove an organization from the consortium it is working from that org but not when both are there
Any idea how to resolve this??
Generally, this error occurs if the chaincode name used in the transaction doesn't match the name used when the chaincode is deployed into the network.
Sometimes this happens if the Chaincode isn't instantiated or isn't defined in the channel. It is better to inspect Docker containers to know about the reason behind this error and make sure that the chaincode names are the same(be aware of upper/lower cases)
If you are running FB test network you can use
./monitordocker.sh fabric_test
So the problem was with the script to create anchor peer for the organization the error was leaking through bash. After adding anchor peers for both organizations things resolved, and I am able to do transactions.
The problem may be come from configtx.yaml, you have to place all the "MSPDir" properly and when you will give command, you have to set environment variable according to that "MSPDir".

error while adding new organization in hyperledger fabric -1.0

I have downloaded and setup the hyperledger fabric network in my CentOs system. I am able to start the first network with default two organization (Org1 and Org2). Also each organization is having two peers(peer0, peer1). Now I am trying add one more Organization with one peer.
I have made changes in below files
first-network/crypto-config.yaml
first-network/configtx.yaml
first-network/docker-compose-cli.yaml
first-network/base/docker-compose-base.yaml
first-network/script/script.sh
now while trying to up the network. Below exception is coming
Having all peers join the channel...
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org1MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
2017-09-06 06:40:53.134 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2017-09-06 06:40:53.134 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2017-09-06 06:40:53.136 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2017-09-06 06:40:53.136 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0A89070A5B08011A0B08F5B0BECD0510...742FDE921B171A080A000A000A000A00
2017-09-06 06:40:53.136 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 152A1C5D481840FB755E98925E0D346271894F15AB69E694C03BEC962E523A50
Error: proposal failed (err: rpc error: code = Unknown desc = Failed to deserialize creator identity, err Expected MSP ID org1MSP, received Org1MSP)
Usage:
peer channel join [flags]
Flags:
-b, --blockpath string Path to file containing genesis block
Global Flags:
--cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint
--logging-level string Default logging level and overrides, see core.yaml for full syntax
-o, --orderer string Ordering service endpoint
--test.coverprofile string Done (default "coverage.cov")
--tls Use TLS when communicating with the orderer endpoint
-v, --version Display current version of fabric peer server
PEER0 failed to join the channel, Retry after 2 seconds

Resources