fabric
fabric copied to clipboard
How to migrate the world state when updating a chaincode?
Description
Is there a way to migrate the world state recorded by a chaincode with another chain code? It seems there is no means for a chaincode to access data that belong to a different chaincode ID. When updating a chaincode and deploy the new version, the new version of the chaincode gets a new chain code ID. Therefore, above limitation makes it impractical to manage data on Hyperledger in real business, because data has longer life time than chain code (i.e., chain code could be updated to fix bugs, add new features, etc.)
Describe How to Reproduce
- Deploy a chain code.
- Put state from chain code to store some data.
- Update the source code of the chain code, and deploy it. (Assuming it gets new chain code ID)
- Try to read the data that was stored in Step 2.
I think there was an update feature in the works. @muralisrini
However, you could also implement "migrate" transactions, which takes a target chaincode id. This migrate "out" on the old chaincode will collect all worldstate and invokes the migrate "in" transaction on the new chaincode. This way you can transfer all worldstate. (Very inefficient though)
@corecode Right, we can implement a kind of "export" and "import" as workaround. But as you pointed out, it will be very inefficient. I think it will be more efficient if we have "update" as part of the core functionalities.
@sachikoy Upgrade and Terminate are good features to have and hopefully will be a proposal at some point not too far out.
I would very much like to be able to "take over" an active database with a new contract version, as I described in #1217
Hi @muralisrini, @christo4ferris, @corecode, this characteristic is indispensable for a production environment. We need something like chaincode versions/updates or chaincode annex retaining all transactions, worldstate, etc. and the capacity to auditing source code in every update deployment, chaining versions :)
Hi , we have multiple projects with stakeholders requesting for this capability; basically a feature/function when chaincode is updated that the data previously written would not be stuck in the older chaincode container. Are there any plans for this feature?