The Chaincode Upgrade
There are situations when the chaincode source needs to be updated or the endorsement policy should be changed, because a new participant has joined the network. Such cases can be easily handled via a chaincode upgrade workflow.
The chaincode upgrade is very similar to the chaincode deployment. It consists of the same steps, but some of them can be omitted or simplified depending on the goal of the upgrade.
Chaincode upgrade steps
Repackage a chaincode
If chaincode binaries should be updated, a new chaincode package should be created. However, you can reuse the previous package in case no changes were made to the chaincode source.
Install a new chaincode package
Once again, this step is performed only if a new chaincode package was created during the previous step. The chaincode version should also be updated to reflect codebase changes in the chaincode deployment lifecycle.
Approve a new chaincode definition
If chaincode binaries are upgraded, the chaincode version and the package ID should be updated in the chaincode definition. It is also possible to change a chaincode endorsement policy without having to repackage chaincode binaries: channel members simply need to approve a definition with a new policy. A new definition has to increment the sequence variable in the definition by one.
Commit the chaincode definition to a channel
Once a required number of channel participants have approved the same chaincode definition, the definition can be committed to a channel. The commit transaction is performed once and can be triggered by any organization. There is no separate upgrade command as a part of a chaincode lifecycle.
Last updated
Was this helpful?