Re: How to verify that a state in the couchdb matches a transaction in the blockchain? #fabric-sdk-node #database #fabric-questions


David Enyeart
 

It is recommended to use endorsement policy > 1 to ensure that multiple peers are in agreement for each transaction. Similarly you can query multiple peers if the state is in doubt. This will protect from one 'bad' peer that has been corrupted or tampered.

In order to verify the state database matches the blockchain, you'd have to read all blocks and persist the latest valid update for each key. This is exactly what a peer does when it joins a channel. Therefore you could join a new peer to the channel and compare the new peer's state database with the in doubt peer's state database, by querying all the keys (either directly using CouchDB APIs, or have a client page through the full set of data results using chaincode queries). However this itself can be challenging, especially if you are talking about live peers that are constantly getting updated. Therefore a new peer feature is being implemented that will take a snapshot and hash of current state on a running peer at a specific block height, which can then be compared with a snapshot from another existing peer or a newly built peer. For details of this feature see https://github.com/hyperledger/fabric-rfcs/pull/27.


Dave Enyeart

Join fabric@lists.hyperledger.org to automatically receive all group messages.