In Hyperledger Fabric, Blocks locations and validi

2019-04-16 16:27发布

Full disclosure, some users have asked about this but the answers have somehow diverted leaving the actual question unanswered.

So, In Hyperledger Fabric:

  1. Where are the physical block files stored on a peer instance?
  2. How Often or when is the World State validated against the underlying ledger/blockchain?

I know that LevelDB is used for the World State and it can be switched to CouchDB and I read somewhere that the ledger is also indexed in LevelDB but that again could refer to the World State and no one seems to know the location of the ledger.

I have explored the peer instance and the location /var/hyperledger/production/ledgersData which further contains directories like chains, historyLeveldb, ledgerProvider, pvtdataStore and the chains directory do contain the channels and then each channel directory has a file blockfile_000000 and based on my current configurations I have executed number of transactions with some delay in between but I don't see any new blocks created under the location I have mentioned.

What freaks me more is that on every peer I have completely removed the ledger directories recursively and my block chain is still working perfectly fine, which begs the question does the world state actually gets validated or do we have to provide our own implementation to validate the world state against the ledger based on our own needs?

My network's relevant configurations:

OrdererType: Kafka
BatchTimeout: 2s
BatchSize:
  MaxMessageCount: 10
  AbsoluteMaxBytes: 1 MB
  PreferredMaxBytes: 512KB

PS: In the logs from Ordering Service I do see logs saying `Going to wait for newer blocks. maxAvailaBlockNumber=[7], waitForBlockNum=[8] and new blocks are created based on the configurations but I don't any file size change in the blockfile_000000 that I mentioned above.

1条回答
甜甜的少女心
2楼-- · 2019-04-16 16:51

The blockchain is stored in the ledgersData/chains directory in the blockfiles. Each time a block is committed the blockfile will be written to and fsynced.

The state database is saved in LevelDB (ledgersData/stateLeveldb directory) or an external CouchDB. Each time a block is committed the state updates for the block will be committed to the state database.

If the data somehow gets tampered or out of sync between the blockchain and the state database, then endorsement requests to this peer would identify the bad data based on inconsistencies with other peers. If there is any doubt about the integrity of the state database, the state database can be dropped and rebuilt from the blockchain. For a deeper explanation please see the post at https://lists.hyperledger.org/g/fabric/message/4896.

查看更多
登录 后发表回答