How is state database across peers synchronized in hyperledger fabric network? - hyperledger-fabric

I have two organizations with 2 peers running on each organization. I created a channel and joined all the 4 peers to it. The peers use couchdb as state database. Now if I accidentally modify/delete the data stored in one of the peer's couchdb database, how does this peer recover from the changed state and get synchronized with other peers?

If you modify data in the state database, it will not be propagated to other peers. See the detailed answer in the question: Hyperledger Fabric CouchDB updates through Fauxton treated as valid updates, but no record in blockchain

Related

Is there a way to link two nodes in Hyperledger fabric?

I want to have two peers within an organization in which one peer act as a client that only send transactions without storing the ledger, and the other act as normal peer. I read about having lightweight node and full node. But how to make them both related to the same organization in Hyperledger?
All peer nodes are committers in Hyperledger Fabric. Thus, every peer node stores the ledger. If a node does not store the ledger, it may be a client or some kind of proxy, but not a peer node. Please, refer to the document where you have read about lightweight and full nodes, as it may be not referring to peers.
Anyway, every node is related to its organization through its MSP.

Can two peers share the same CouchDB container?

can two peer containers of the same org share the same CouchDB database on Fabric v2.0?
No, They don't share same couchdb. Every peer maintain its own couchdb and communicate via gossip protocol to be in sync with each other.
Answer is No
Few points to support this, as below:
CouchDB is used as a state database by the peers
Every peer has an identity and it has to be a separate couch instance in order to store the state data
state data may contains public data and private data when you enable private data mode and it has to be separate and dedicated instance

Managing privacy in hyperledger fabric

I have use case where I have 2 organizations and they are sharing some data and some data is kept private. Now after couple of years, I have a requirement to share some more data or restrict some data from/to organization. Is it possible in Hyperledger Fabric? If yes please let me know how. I can see there is private data in Hyperledger fabric but the issue is that the data entered while org was not allowed to have that data will never be available for that same org after allowing that org.
If you have any idea please let me know.
Thanks
In Hyperledger Fabric v1.2 it is possible to update a private data collection configuration definition or add a new collection at chaincode upgrade time. The updated configuration applies from the time the upgrade transaction is committed onwards. Newly added organizations will receive private data for subsequent collection transactions.
In future versions of Hyperledger Fabric, there is intent to add an option that allows newly added organizations to pull (reconcile) prior private data for the collections that they are now entitled to.

Does each channel create a different blokchcain in hyperledger-fabric?

In hyperledger fabric, we can have multiple state databases corresponding to each channel the node has joined. Do we also have multiple blockchains corresponding to each channel for a node?
Note that in Fabric there is only one ledger per channel. Ledger in Fabric contains two components. One is called the world state which stores the latest value of the keys. Another one is called blockchain which stores all the transaction log that leads to the world state. So back to your question, there should be one state databases (world state) and blockchain per channel. Each peer in the channel hold a copy of the ledger and thus should have a consistent view on the world state within the channel.
For more information, you may refer to the following:
Docs on Ledger
https://hyperledger-fabric.readthedocs.io/en/latest/ledger/ledger.html

Hyperledger communication between multiple machine

I have created a network composed by two nodes using this tutorial: Multiple Machine.
In the node with orderer and ca installed, I can use the composer-playground to interact with the blockchain. Instead, analysing the logs of the docker on the second node, I am able to see the communication between the nodes but I am not able to access the data.
How can I access data on the second machine?
It is a simple node connect to the first node (where is installed the orderer and the ca).
Thanks,
What do you mean by accessing the data?
In Hyperledger Fabric the ledger data is composed of two components i.e. World State and Transaction History Log (the blockchain).
Here World state refers to the most recent (current) state of the assets you have and Transaction History log refers to the transaction executed on these assets. Assets or Key Value set when using CouchDB as the World State allows you to have KeyValue with Value as JSON documents.
The World State by default is stored in levelDB or couchDB, if you have docker containerized network the World State levelDB is stored on the peer container while using couchDB sets up its own couchDB container associated with each peer. The couchdb for each peer can be accessed from host machine using http://couchdbIp:port
The Transaction log get's stored in the underlying file system as blockFiles somewhere under location /var/hyperledger/ledgerdata or something in the peer container.
When you mention Orderer, which is another component like peer, is a docker container assigned the role of making sure that transactions are properly ordered and verified that their endorsement are valid. This gets complicated as you go to having multiple ordering service nodes and requires Kafka implementation rather than the default SOLO implementation. You can read about each of these implementations in Hyperledger Fabric official documentation.
Also CA is associated with each organization responsible for establishing chain of trust is another component of Hyperledger Fabric that signs certificates of network components like organization peers, client and participants following PKI.
The Playground will connect to the Fabric based on the connection profile (connection.json) for the Business Network Cards you have. If you want to specifically connect to second node you could modify a card.
But remember that Playground is a development and test tool not a production tool so you shouldn't worry too much about hitting different containers with it - particularly as the data will be the same replicated across Peers.

Resources