What is chaincode's transaction count - hyperledger-fabric

This is what my network setup.
peer1.org1.example.com
peer1.org2.example.com
peer0.org1.example.com
peer0.org2.example.com
ca_peerOrg2
ca_peerOrg1
orderer.example.com
After instantiation of my chaincode, I am getting transaction count as 0 in chaincode's tab in hyperledger fabric explorer. But It is 4 in dashboard and channel's tab. What is the reason? Can someone please explain?

The instantiation of the chaincode is a transaction itself. So for each one of the peers that you instantiate a chaincode you will have a transaction.

Related

Can anyone tell me the what 「propose」,「writeBlock」,「StoreBlock」,「Validate」「commit」stage means in Hyperledger Fabric?

Here is the log of Hyperledger Fabric test network. There are 2 peer node(peer0.org1.example.com & peer0.org2.example.com) and 2 orderer node(orderer.example.com & orderer2.example.com).
My question is what 「writeBlock」,「StoreBlock」,「Validate」「commit」stage actually does? I know that at 「propose」stage, a chosen orderer(in this case, orderer.example.com) will create a block and then send the created block to other orderer such as orderer2.example.com. However, I don't understand what orderers does at「writeBlock」stage. Do they sign the created block at 「writeBlock」stage? Next, peer nodes received the block from who? orderer.example.com or orderer2.example.com? In my guess, I think it's from orderer.example.com but I'm not sure.
I don't understand what orderers does at「writeBlock」stage.
I'm not sure about those stages (writeBlock looks self-explanatory). I don't know about "StoreBlock", it isn't mentioned in the official docs. I'm wondering which Fabric version you are using.
Next, peer nodes received the block from who?
In a RAFT network you have a leader/follower model. You can think of a leader peer as an entry point/doorman for all communication coming from the ordering nodes. An ordering node sends blocks to the leading peer(s) of each organization; the leading peer is then responsible for distributing those blocks to other peers belonging to the same organization. Distribution is done using gossip protocol.
Hyperledger Fabric is a complex system, with many components and a lot of moving parts.
The log that you are referring to is the log of the orderer node - orderer.example.com. It's a part of the Fabric test network. You can see what's happening in detail by looking at the logs of other Fabric components, such as peer node logs.
The Fabric network has a set of orderer nodes, which are responsible for ordering the transactions and creating blocks in the blockchain.
The orderer nodes are configured to use a consensus algorithm (such as Solo or Kafka) to achieve a consensus about the order of the transactions.
A Fabric network has a set of peer nodes, which are responsible for executing the chaincode (smart contracts) and catching and validating the transactions.
The Fabric test network consists of one orderer node, which is configured to use Solo consensus algorithm. This orderer node is orderer.example.com.
The Fabric test network consists of two peer nodes, which are peer0.org1.example.com and peer0.org2.example.com.
The log that you are referring to is the log of the orderer node - ord

How to add an endorsing peer in hyperledger fabric?

What steps are required in order to add an endorsing peer to a blockchain network (in hyperledger-fabric)? What about promoting a committing peer in an endorsing one?
Should I just alter files crypto-config.yaml and configtx.yaml by adding the new peer?
I am using the fabcar example from the fabric-samples repo (https://github.com/hyperledger/fabric-samples), so should I change the docker-compose(-cli).yaml also? When starting the network with startFabric.sh script, should I just install chaincode on the new peers, or are other steps requires also?
I tried it with just installing a chaincode on the new peers, however I got an error stating that "... Consortium was not met when instantiating the chaincode ..."
Edit:
I was able to install the chaincode on all four peers and instantiate it on the channel. Initial non-query transaction is successful and another one after it. However, after the first two transactions I get:
Failed to submit transaction createInquiry: Error: Peer localhost:8051 has rejected transaction "e8a83c12bfbcae97c7a3f2baaad7735fe8b44195a0ce252a3533a7b4a2a8103b" with code "ENDORSEMENT_POLICY_FAILURE"
can you stop, remove and kill containers and try once again to instantiate.

channel ‘mychannel’ not found in orderer when restart kafka, zookeeper and orderer

I am testing the Kafka mode in Fabric Network, after I create a channel
named 'mychannel', I joined two ORG in it. After these actions, I tried to use 'down' and 'up' command to refresh the kafka、zookeeper and the orderer's containers.In this way, I want to test if a peer can persistent 'channels' in different fabric network.
When tailing the logs of Orderer, I found the problem :
[common.deliver] deliverBlocks -> DEBU dc9 Rejecting deliver for 192.168.11.61:60156 because channel mychannel not found
and I used the kafka shell tool to check topic list, and find the 'mychannel' topic disappeared.
After doing above, I create a new channel 'mychannel' which used the same 'channel.tx' . And I found the error in log:
UTC [common.deliver] deliverBlocks -> ERRO b1b [channel: mychannel] Error reading from channel, cause was: NOT_FOUND
I used command:
peer channel getinfo -c mychannel
in one org's peer , and get info, the block height is 16:
Blockchain info: {"height":16,"currentBlockHash":"gHOfUnVRT0pGMRssz8fUXWH4jdH/1hcPUPLBqau7L9c=","previousBlockHash":"yvKUrJDg3+60Sbc0HHKs+N5vVkW2WBJWhy9TLFGmMug="}
I guess the orderer genesis block's height is 0, and can't match the current block height.
How can I fix this problem? Can I use channel update method to update the channel config?
kafka mode: 4 kafka brokers, 3 zookeepers
1 orderer
2 orgs
restart orderer and kafka cluster(cmd: 'docker-compose down & up')
It appears that you were not using externally mounted volumes with your Kafka, Zookeeper and Orderer containers. When you run docker-compose down it actually destroys the containers. If you want to start/stop the containers, you need to use docker-compose stop and docker-compose start.
If you want to preserve data in the event that the containers are destroyed (or even to upgrade them), then you need to attach external volumes to your containers.

Hyperledger Fabric: Endorsement policy

It's possible in Hyperledger Fabric to specify that all peers in an organization must endorse the transactions?
I'll try to explain better what I am doing. Starting from the examples in the fabric-samples repository, I want to realize a scenario in which I have two separate nodes (on two different VM): on the first one I have my first peer (peer0.org1.example.com), the orderer and the fabric-ca; on the second one I have my second peer (peer1.org1.example.com).
For now, I am been able to do that: I install the chaincode on both peers and instantiate it on the channel, so I can (from both the peers on the two VMs) send transactions. But when I instantiate the chaincode, I can only say that only one of the two peer is needed to endorse the transactions (I am instantiating it with something like: docker exec cli peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n mychaincode -l java -v 1.0 -c '{"Args":["init"]}' -P "OR('Org1MSP.member')" ).
Can I specify that both peer0.org1.example.com and peer1.org1.example.com must endorse all transactions? In my configuration they both belong to the Org1 organization, I wouldn't want to split them in two ones.
Of course you can. With the syntax OutOf(), you can set how many peers needs to sign.
For example:
OutOf(1, 'Org1.member', 'Org2.member')
OutOf(3, 'Org1.member')
OutOf(2, 'Org1.member', 'Org2.member', 'Org3.member')
You can check more of this sintax here.

What install and instantiation chaincode really mean in hyperledger fabric? and what are the differences between them?

In the hyperledger fabric documentation, there are 2 terms used
1. Install the chaincode on peers and
2. Instantiate the chaincode on the channel
What are the major differences between these two?
In the documentation it said that a chaincode can be installed on multiple peers but can be instantiated once. I understood this point as a channel only needs the information about the channel.
I was following the balance-transfer example, so after channel creation, peers need to be joined to that channel.
There are 2 peers which joined the channel ["peer0.org1.example.com", "peer0.org1.example.com"], so when I am instantiating the chaincode it is creating 2 docker images of chaincode
dev-peer0.org1.example.com-chaincode-v0
dev-peer1.org1.example.com-chaincode-v0
What these 2 images really mean?
Isn't initializing the chaincode means for the channel?
Or channel initialize it on all the peers who joined it?
Where actually this initialization is happening?
Thanks!
Thanks to #PaulO'Mahony and #kajuken for the resources and explanation.
Following are the summary of my doubts:
A chaincode runs in a Docker container that is associated with any peer that needs to interact with it.
Chaincode is installed on a peer, then instantiated on a channel.
All members that want to submit transactions or read data by using a chaincode need to install the chaincode on their peer.
Instantiation will input the initial data used by the chaincode, and then start the chaincode containers on peers joined to the channel with the chaincode installed.
Note that only one network member needs to instantiate a chaincode. If a peer with a chaincode installed joins a channel where it has already been instantiated, the chaincode container will start automatically.
a chaincode is installed onto the file system of every peer that joins a channel, the chaincode must then be instantiated on the channel so that peers can interact with the ledger via the chaincode container. The instantiation performs any necessary initialization of the chaincode. This will often involve setting the key value pairs that comprise a chaincode's initial world state.
A peer can the install the chaincode once, and then use the same chaincode container on any channel where it has been instantiated.
References:
install and instantiate the chaincode
instantiate the chaincode
What these 2 images really mean?
Isn't initializing the chaincode means for the channel?
Yes and no. Every peer needs the same version of the chaincode installed on itself since everybody needs to be able to execute and verify incoming queries/invokes.
So there are 2 steps to do.
install the chaincode on every peer on the channel
instantiate the chaincode on the channel
Where actually this initialization is happening?
So the instantiating of chaincode is happening last after every peer has "knowledge" of the chaincode and it can be verified.

Resources