viswa
viswa

Reputation: 93

issue in consuming existing data after re-build and deploy nodes

i created one transaction using . After that i made some changes in code and build and deploy the nodes successfully. I tried to consume previously created data to create new data. But it led to Contract constraints failed error. But i didn’t get any error at the time of creating new data and consuming the same to create another transaction at that instance.

Upvotes: 0

Views: 118

Answers (1)

balajimore
balajimore

Reputation: 497

TransactionVerificationException.ContractConstraintRejection

This exception is thrown when you have existing states in the vault and you updated the contract code and redeployed.

  1. Every time at the node startup CorDapp Jar are scanned and Jar which has Contract classes are uploaded to attachment storage, and the hash of the Jar used as Attachment ID to attach the contract to a transaction.

  2. Now, consider, you have a first fresh version of CorDapp - Attachment ID is: 3B6CA18330500C738455444115C49769D54074CE3CFFB194D8943F34494DB0A4

  3. To create State on vault, you build the transaction, Corda auto-attach the contract using Attachment ID given above.

  4. Then, consider, you changed the code and re-ployed the CorDapp, now jar hash changed, new Attachment ID is: F054BA8C1A67BAABF58539F8718B8A62DC770157D9F1D01434B86E73AD2A9217

  5. My finding, when you create any new the transaction, Corda uses new/recent Attachment ID to attach specified contract.

  6. For example, You want to update State already present on vault.

    a. You created a transaction which has one input and it's output state.

    b. You sent this transaction for verification.

    c. There is check verifies that input state contract Attachment Id and current transaction Attachment Id must be same.

    d. But right now input state pointing to old Attachment ID and transaction pointing new Attachment ID. Here check fails and throws a TransactionVerificationException.ContractConstraintRejection exception.

Upvotes: 1

Related Questions