I am going through this documentation and I have several uncertainties.
Performing explicit contract and state upgrades
- Preserve the existing state and contract definitions
- Write the new state and contract definitions
- Create the new CorDapp JAR
- Distribute the new CorDapp JAR
- Stop the nodes
- Re-run the network bootstrapper (only if you want to whitelist the new contract)
- Restart the nodes
- Authorise the upgrade
- Perform the upgrade
- Migrate the new upgraded state to the Signature Constraint from the zone constraint
Questions:
1. Preserve the existing state and contract definitions 2. Write the new state and contract definitions 3. Create the new CorDapp JAR
How do I do that? is it meant only to preserve jars with contracts and states on nodes, not preserving them in source code? If I do not preserve them in source code then how can I create the upgrade method?
interface UpgradedContract<in OldState : ContractState, out NewState : ContractState> : Contract {
val legacyContract: ContractClassName
fun upgrade(state: OldState): NewState
}
If I do not preserve old state in source code, then shoud I name the jar differently each time I need to do an upgrade? Can old jars be reoved from the node when the upgrade was completed?
6. Re-run the network bootstrapper (only if you want to whitelist the new contract) 8. Authorise the upgrade Am I right that only those 2 steps are related to Explicit contact upgrades? And If I use implicit flow with signature, then I need to skip only those two steps, while the others are still aplicable and must be performed?
9. Perform the upgrade Should this be done for each state separately by the owner of the state? In that case should I run it on each node for specific contrcats where the node is the participant of the state? (In doc it is mentioned to be run on single node - but what id=f a single node is not participant of some state)
Other questions
This section describes explicit contracts and states update. https://docs.corda.net/upgrading-cordapps.html#performing-explicit-contract-and-state-upgrades while signature constraint section (https://docs.corda.net/api-contract-constraints.html#signature-constraints) does not describe an update process for states. is it the same as for explicit upgrades with the difference only in steps 6,8 or it is somewhat completely different? Do I need to create the function transforming old states to new states in that case? if not , then how the old states will be handled by new flows?