0

Suppose I have started fabric with two peers in a single organization. After running my application/rest-server through composer and submitting transactions. I was able to make changes in the values of Couchdb instance of peer1 by going on the address http://localhost:6984/_utils/#/_all_dbs. Now, the two peers are not in sync with each other - application should throw some error but it isn't. Mostly, because it is getting data just from the first peer i.e. peer1.

So, firstly how can I get data from multiple peers - if I want to get data from peer2 aswell?

Secondly, why it is getting data from state database not from ledger?

Thirdly, data should remain in sync even after committed how can I configure this? if some peer tampered its database it should be notified. I have read consensus part and got that it is for the correct order of transactions and blocks but what if someone tampered with the state database?

Zohaib Sohail
  • 310
  • 3
  • 14
  • see answers here ->https://stackoverflow.com/questions/48355666/data-storage-in-hyperledger-fabric?rq=1 (1st part) and here -> https://stackoverflow.com/questions/50064406/how-does-hyperledger-fabric-ensure-the-integrity-of-state-in-couchdb?rq=1 and here -> https://stackoverflow.com/questions/49934312/how-your-data-is-safe-in-hyperledger-fabric-when-one-can-make-changes-to-couchdb/49987345 and – Paul O'Mahony Nov 05 '18 at 11:48

2 Answers2

0
  1. If you're able to change the entries in state database for 1 peer, with a strong endorsement policy such as AND, your transactions will fail validation because of difference in the data for the two peers. This is one of the most important pros of decentralized network.

  2. State database and the Ledger are not same thing. this should help you in understanding the differences between the both.

  3. Every participating member of a Hyperledger Fabric network is a known entity per se (since Fabric being a permissioned blockchain). Said that, a change in state database of a single peer will again lead to scenario #1 above, where the Read/Write sets in a transaction won't match for multiple peers (as their state databases contain different values of an asset). This will lead to invalidation of the transactions. Now it just becomes a question of how can the network know about the corrupted peer(and subsequent state db). There can be multiple solutions for the same.

But most importantly, Fabric being a permissioned blockchain network, the state databases must be very strictly access protected and authorized outside of the network too.

tortuga
  • 737
  • 2
  • 13
  • 34
0

the fact that you modified the world db doesn't mean anything. any changes you make to that database are not a representation of the ledger.

The ledger itself, the blocks and the transactions they contain are stored in a physical file. The world state db is simply a collection of the current state for each asset. This is a good design because an application will not care about every state change an item went through, it will only care about the current state. The world state db can easily be recreated whenever there is a need for it.

Now, you should not make any changes directly to to the world state db, because that's useless. Any change needs to go through the proper process, via a proposal submitted by a peer which then goes through the orderer. Only when everything is followed, does a change go onto the ledger and get synced with every peer and the world state db will reflect that.

In terms of where you should get the data, the answer is that it doesn't matter. Each peer will have an exact copy of the ledger so if you get data from peer 1 or 2 is irrelevant, it will be the same thing.

Again, just because you changed the world state, that doesn't mean anything, the ledger is untouched, but your application reports the current state from the world state db, which is now incorrect because of your change.

Andrei Dragotoniu
  • 6,155
  • 3
  • 18
  • 32