1

How do we normally remove/clear all the test data from the Hyperledger Fabric network?. we do the following approach to run the tests (assuming an HLF network is up and running)

  1. Run the e2e test against the network
  2. If the test passes all the rules then proceed to the next stages in the pipeline

Once the test is run some data's are available in the world state and blockchain, so how do we remove the data without rebuilding the network

Options

  1. Remove the DB associated files from the var/hyperledger/production folder , but I am not sure this is the right way to this.
shamon shamsudeen
  • 5,466
  • 17
  • 64
  • 129

2 Answers2

1

The truth is, removing the database and restarting the peer may be the fastest way to start over depending on the situation.

The officially supported method however is using the ledger reset feature, which allows you to return your ledgers to the genesis block. You can reset your ledger via the command peer node reset.

You can also roll you ledgers back to a previously committed block using peer node rollback -c <channel> -b <block_number_to_roll_back_to>

Though I would recommend you look at each command and compare its speed to simply removing the database and see which is most tolerable for your usecase.

You can find the official documentation here: https://hyperledger-fabric.readthedocs.io/en/release-2.0/commands/peernode.html#peer-node-reset-example

lindluni
  • 505
  • 4
  • 6
  • 1
    `peer node reset` will reset all blocks in that peer to the genesis block, then when the peer is started after performing the reset it will sync again with the other peers or orderers to fetch all removed blocks and commit the blocks up to the pre-reset height, the ledger is immutable You can't remove blocks by this way, to update the world state you have to submit another transaction to delete the test data, or tear down all network and start it again from scratch – Yasser Mas Nov 22 '20 at 12:55
0

Assuming that you're talking about the initialized data from the samples network, the test data is already a part of the ledger, so it can not be removed. The data can, however, be removed from the current state by updating the chaincode and adding a delete function. After successfully updating your new chaincode to the ledger, you should be able to delete the test data from the function you have created. You can later remove the function by updating the chaincode again

For reference, delete can be implemented by DelState(). You can refer it from marbles_chaincode.go

  • We are not using the fabric samples to develop instead keep that as a reference and built everything from scratch(network,chain codes e) – shamon shamsudeen May 07 '20 at 07:37