Context: We have recently been making changes to the contract code in the same CorDapp before we realised that you can't just swop out the old CorDapp with a new CorDapp plugin given the attachment constraint placed on transactionstate. As such old state objects which references the old attachment hash will throw out an error of ''ContractConstraintRejection'' when a new CorDapp JAR is put in placed of the old one.
Resolution: Upgrade the contract in the following steps -
- Amend the original state / contract to reflect the new desired implementation
- Test the new state and contract
- Stop all nodes on the business network
- Produce a JAR file and distribute it to all required parties
- Start all nodes on the network
- All nodes should run the contract upgrade authorisation flow for each state that requires updating
- For each state, one node should run the contract upgrade initiation flow
Guidance required:
- On step 4, how do we produce just a JAR file that contains only the updated new contract? I had clone a template and added just a contract code + api calls to do the upgrade, compiled the code and added to a node. When i restart the node, I can't seem to access those api in the new JAR to do the upgrade.
- On step 6 & 7, I have tried writing an web API to call the authorisation in all the nodes, followed by another call to ''upgrade flow''. I kept hitting the wall. If I were to just do RPC calls, is it better to run a script in IDE like this (https://github.com/ragmondo/corda-nodeinfo). Are there any examples I could reference on authorisation + calling the upgrade flow. The tutorial on the docsite is not exactly clear (https://docs.corda.net/contract-upgrade.html).