Search code examples
blockchaincorda

How can I change types of Contract Constraints to Signature constraint in corda production env


When I update corda contract app I got the error

java.lang.IllegalArgumentException: An attachment has been explicitly set for contract com.fna.contracts.contract.InvoiceContract in the transaction builder which conflicts with the HashConstraint of a state.

And about data in vault I found contract type is "HashAttachmentConstraint".but in dev env is "Signature Constraints". Can I change HashAttachmentConstraint to Signature Constraints in production env

enter image description here


Solution

  • Looking at the image, it is clear that you have some states which use HashConstraint. I would recommend you to follow the below steps and perform a migration of HashConstraint States to Signature Constraint.

    1. Stop your node.
    2. Sign the jar. To externally sign the jar use the jarsigner. By default, if you do not disable signing in Corda version 4, the jar is signed when you run the deployNodes task.
    3. Replace the old jar with this newly signed jar.
    4. Start the node by disabling the hash constraint, by setting the Java system property to -Dnet.corda.node.disableHashConstraints=”true”.
    5. Start the node.
    6. Run a flow that consumes old Hash constraint states and issues new signature constraint states. You should see the new states using signature constraints.

    You can refer to a sample that does this here.

    Take a look at this blog to read more on this topic.

    Finally, you can also take a look at a video which shows how to do the same.

    You can find more information on contract migration in docs as well.