ashu
ashu

Reputation: 1347

Corda explicit contract upgrade NoSuchElementException: List is empty

I am trying to upgrade the Corda contracts. Currently we have an uber jar having state, flows and contracts. We are using explicit upgrade mechanism by utilising UpgradeContractUsingLegacyConstraint interface to break uber jars in separate jars.

In our network, there is one observer node, which tracks all the transactions happening between other nodes in the network. Thus, in this scenario, we ran Authorise flow in all the nodes in network and then ran Initiate flow in the observer node. While authorise flow ran successfully in all nodes without any error, Initiate flow has two issues.

  1. Some of the flows are failing. We are getting error multiple instance of NoSuchElementException. The stack trace is mentioned below
  2. Some of the flows remain pending. In Jolokia monitoring, we are getting similar statistics where some remain in in-flight state. In Corda SSH shell too, we are getting pending trades after running flow watch command. We tried to restart the system, but the issue remains persistent in observer node.

What should be the next step or recommended way to upgrade the contracts. I am using Corda v3.3 on Ubuntu 16.04, Cordite network map and taking reference from github repository to upgrade the contract ( https://github.com/amolpednekar/contract-state-upgrades/blob/master/cordapp/src/main/kotlin/com/upgrade/Client.kt ).

Stacktrace:

[WARN ] 2019-05-22T22:16:31,568Z [Node thread-1] flow.[fa8a213f-8de7-4cd8-8d41-8493bbc9cecf].run - Terminated by unexpected exception {}
java.util.NoSuchElementException: List is empty.
    at kotlin.collections.CollectionsKt___CollectionsKt.single(_Collections.kt:472) ~[kotlin-stdlib-1.1.60.jar:1.1.60-release-55 (1.1.60)]
    at kotlin.collections.CollectionsKt___CollectionsKt.single(_Collections.kt:454) ~[kotlin-stdlib-1.1.60.jar:1.1.60-release-55 (1.1.60)]
    at net.corda.core.flows.ContractUpgradeFlow$Initiate.assembleTx(ContractUpgradeFlow.kt:77) ~[corda-core-3.3-corda.jar:?]
    at net.corda.core.flows.AbstractStateReplacementFlow$Instigator.call(AbstractStateReplacementFlow.kt:64) ~[corda-core-3.3-corda.jar:?]
    at net.corda.core.flows.AbstractStateReplacementFlow$Instigator.call(AbstractStateReplacementFlow.kt:50) ~[corda-core-3.3-corda.jar:?]
    at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:96) [corda-node-3.3-corda.jar:?]
    at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:44) [corda-node-3.3-corda.jar:?]
    at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1092) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:788) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_201]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_201]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_201]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_201]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_201]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_201]
    at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$1$thread$1.run(AffinityExecutor.kt:62) [corda-node-3.3-corda.jar:?]
[WARN ] 2019-05-22T22:16:31,574Z [Node thread-1] flow.[5856148a-d233-43c4-ac20-396b9a91f6c0].run - Terminated by unexpected exception {}

EDIT: Some other errors captured:

[WARN ] 2019-06-03T16:36:22,357Z [Node thread-1] flow.[2aec6ee2-2e14-43f5-81ce-b301c4876e0a].run - Terminated by unexpected exception {}
java.lang.ClassCastException: io.corp.contract.DefaultContract cannot be cast to net.corda.core.contracts.UpgradedContract
        at net.corda.core.flows.ContractUpgradeFlow$Authorise.call(ContractUpgradeFlow.kt:38) ~[corda-core-3.3-corda.jar:?]
        at net.corda.core.flows.ContractUpgradeFlow$Authorise.call(ContractUpgradeFlow.kt:31) ~[corda-core-3.3-corda.jar:?]
        at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:96) [corda-node-3.3-corda.jar:?]
        at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:44) [corda-node-3.3-corda.jar:?]
        at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1092) [quasar-core-0.7.9-jdk8.jar:0.7.9]
        at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:788) [quasar-core-0.7.9-jdk8.jar:0.7.9]
        at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) [quasar-core-0.7.9-jdk8.jar:0.7.9]
        at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) [quasar-core-0.7.9-jdk8.jar:0.7.9]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_201]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_201]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_201]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_201]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_201]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_201]
        at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$1$thread$1.run(AffinityExecutor.kt:62) [corda-node-3.3-corda.jar:?]

Also this was found for one our contract upgrade

[WARN ] 2019-06-03T17:44:26,859Z [Messaging DLJKqkjV9pKTqG5nKbQQ3o5B1hPj1zjrYxDYpbhPENXdR] messaging.P2PMessagingClient.sendWithRetry - Reached the maximum number of retries (3) for message ClientMessageImpl[messageID=0, durable=true, address=internal.peers.DL8itTRrD1LvKjd5sQ9DwX59KmZ42PTa964nJPfL6jf1VC,userID=null,properties=TypedProperties[platform-version=3,corda-vendor=Corda Open Source,release-version=3.3-corda,platform-topic=platform.session,_AMQ_DUPL_ID=23190134-6514-4165-8277-0e3df48e2678,corda_p2p_message_type=session_init]] redelivery to internal.peers.DL8itTRrD1LvKjd5sQ9DwX59KmZ42PTa964nJPfL6jf1VC {}
[WARN ] 2019-06-03T17:44:26,941Z [Messaging DLJKqkjV9pKTqG5nKbQQ3o5B1hPj1zjrYxDYpbhPENXdR] messaging.P2PMessagingClient.sendWithRetry - Reached the maximum number of retries (3) for message ClientMessageImpl[messageID=0, durable=true, address=internal.peers.DL8itTRrD1LvKjd5sQ9DwX59KmZ42PTa964nJPfL6jf1VC,userID=null,properties=TypedProperties[platform-version=3,corda-vendor=Corda Open Source,release-version=3.3-corda,platform-topic=platform.session,_AMQ_DUPL_ID=2e2cde97-1e3d-4ce9-b7af-01ab61a88114,corda_p2p_message_type=session_init]] redelivery to internal.peers.DL8itTRrD1LvKjd5sQ9DwX59KmZ42PTa964nJPfL6jf1VC {}

Upvotes: 0

Views: 322

Answers (1)

tudor
tudor

Reputation: 131

From the stacktrace, it looks like the initiator is not a participant in the original state.

Upvotes: 0

Related Questions