fabric icon indicating copy to clipboard operation
fabric copied to clipboard

How to migrate the world state when updating a chaincode?

Open sachikoy opened this issue 9 years ago • 6 comments

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

  1. Deploy a chain code.
  2. Put state from chain code to store some data.
  3. Update the source code of the chain code, and deploy it. (Assuming it gets new chain code ID)
  4. Try to read the data that was stored in Step 2.

sachikoy avatar May 20 '16 08:05 sachikoy

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 avatar May 20 '16 09:05 corecode

@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 avatar May 25 '16 06:05 sachikoy

@sachikoy Upgrade and Terminate are good features to have and hopefully will be a proposal at some point not too far out.

muralisrini avatar May 25 '16 14:05 muralisrini

I would very much like to be able to "take over" an active database with a new contract version, as I described in #1217

kletkeman avatar Jun 09 '16 15:06 kletkeman

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 :)

jjmiranda avatar Nov 20 '16 16:11 jjmiranda

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?

jonathan-yk-tan avatar Nov 24 '16 08:11 jonathan-yk-tan