Я пытаюсь обновить контракт, следуя этой статье https://docs.corda.net/contract-upgrade.html, затем после выполнения ContractUpgradeFlow не возникает ошибка, но когда хранилище запросов кажется, что состояние все еще принадлежит старому контракту.
В таблице оно уже вставлено в node_contract_upgrades
![table = node_contract_upgrades](https://i.stack.imgur.com/FRYQm.png)
Но при запросе состояния из хранилища я все еще получаю старый контракт, и если я совершаю транзакцию с (старое состояние + новый контракт), он покажет ограничение контракта
Flow Internal Error : java.util.concurrent.ExecutionException: net.corda.core.contracts.TransactionVerificationException$ContractConstraintRejection: Contract constraints failed for th.co.jventures.ddlp.cordapp.contracts.CustomerContractV01, transaction: 418A9A1562A1A7F3C465EC2CC5DDEFB83F5D9C71269EDF83BFBA1094274F926F
Здесь мой client.kt для обновления потока выполнения
<pre>`<pre>fun main(args: Array<String>) {
UpgradeContractClient().main(args)
}
/**
* A utility demonstrating the contract upgrade process.
* In this case, we are upgrading the states' contracts, but not the states
* themselves.
**/
private class UpgradeContractClient {
companion object {
val logger: Logger = loggerFor<UpgradeContractClient>()
}
fun main(args: Array<String>) {
val clientDs = CordaRPCClient(parse("localhost:10009"))
val dsProxy = clientDs.start("user1", "test").proxy
val clientPah = CordaRPCClient(parse("localhost:10008"))
val pahProxy = clientPah.start("user1", "test").proxy
// Authorise the upgrade of all the State instances using OldContract.
println("Doing Authorise")
listOf(dsProxy, pahProxy).forEach { proxy ->
// Extract all the unconsumed State instances from the vault.
val stateAndRefs = proxy.vaultQuery(CustomerStateV01::class.java).states
println("Found customerState=${stateAndRefs.size} for node : ${proxy.nodeInfo()}")
// Run the upgrade flow for each one.
stateAndRefs.filter { stateAndRef ->
stateAndRef.state.contract == CustomerContractV01.CONTRACT_ID
}.forEach { stateAndRef ->
proxy.startFlowDynamic(
ContractUpgradeFlow.Authorise::class.java,
stateAndRef,
CustomerContractV02::class.java).returnValue.getOrThrow()
}
println("Finished")
}
Thread.sleep(5000)
// Initiate the upgrade of all the State instances using OldContract.
println("Doing Initiate")
dsProxy.vaultQuery(CustomerStateV01::class.java).states
.filter { stateAndRef ->
stateAndRef.state.contract == CustomerContractV01.CONTRACT_ID
}
.forEach { stateAndRef ->
dsProxy.startFlowDynamic(
ContractUpgradeFlow.Initiate::class.java,
stateAndRef,
CustomerContractV02::class.java)
}
// Log all the State instances in the vault to show they are using NewContract.
dsProxy.vaultQuery(CustomerStateV01::class.java).states.forEach { println("${it.state}") }
dsProxy.vaultQuery(CustomerStateV01::class.java).states.forEach { println("${it.state.contract}") }
}}`
А вот мой контрактV02
class CustomerContractV02 : UpgradedContract<CustomerStateV01, CustomerStateV01>{
override val legacyContract: ContractClassName
get() = CustomerContractV01.CONTRACT_ID
override fun upgrade(state: CustomerStateV01): CustomerStateV01 {
return state
}
Я ожидаю, что состояние со старым контрактом должно выполнять транзакциюс новым контрактом или я неправильно понял концепцию?