corda / token-sdk

Corda Tokens SDK
Other
79 stars 76 forks source link

RedeemFungibleTokens flow not working when passing observers #117

Closed chrisciszak closed 5 years ago

chrisciszak commented 5 years ago

We are trying to implement Token SDK into our existing project. Issuance and Move commands are seem to be working fine. However, RedeemFungibleTokens fails when observers are passed to the flow. I replicated the problem with cordapp-template-kotlin TokenSDK branch.

The error is below:

OBSERVER NODE:

invocation_timestamp=2019-07-10T13:59:56.665Z, origin=O=PartyB, L=New York, C=US, session_id=dc0b167d-2ca1-41a3-a98e-2f6701e3ea6e, session_timestamp=2019-07-10T13:59:56.665Z, thread-id=224} [WARN ] 2019-07-10T13:59:57,752Z [Node thread-1] interceptors.DumpHistoryOnErrorInterceptor.executeTransition - Flow [2f12da1e-014d-4d9f-b765-a7c877778a03] error [errorCode=scrdwz, moreInformationAt=https://errors.corda.net/OS/4.1/scrdwz] {fiber-id=10000001, flow-id=2f12da1e-014d-4d9f-b765-a7c877778a03, invocation_id=dc0b167d-2ca1-41a3-a98e-2f6701e3ea6e, invocation_timestamp=2019-07-10T13:59:56.665Z, origin=O=PartyB, L=New York, C=US, session_id=dc0b167d-2ca1-41a3-a98e-2f6701e3ea6e, session_timestamp=2019-07-10T13:59:56.665Z, thread-id=224} java.lang.IllegalArgumentException: Payload invalid at net.corda.core.internal.InternalUtils.checkPayloadIs(InternalUtils.kt:518) ~[corda-core-4.1.jar:?] at net.corda.node.services.statemachine.FlowSessionImpl.receive(FlowSessionImpl.kt:67) ~[corda-node-4.1.jar:?] at net.corda.node.services.statemachine.FlowSessionImpl.receive(FlowSessionImpl.kt:71) ~[corda-node-4.1.jar:?] at net.corda.confidential.IdentitySyncFlow$Receive.call(IdentitySyncFlow.kt:113) ~[corda-confidential-identities-4.1.jar:?] at net.corda.confidential.IdentitySyncFlow$Receive.call(IdentitySyncFlow.kt:84) ~[corda-confidential-identities-4.1.jar:?] at net.corda.node.services.statemachine.FlowStateMachineImpl.subFlow(FlowStateMachineImpl.kt:329) ~[corda-node-4.1.jar:?] at net.corda.core.flows.FlowLogic.subFlow(FlowLogic.kt:314) ~[corda-core-4.1.jar:?] at com.r3.corda.lib.tokens.workflows.flows.redeem.RedeemTokensFlowHandler.call(RedeemTokensFlowHandler.kt:27) ~[?:?] at com.r3.corda.lib.tokens.workflows.flows.redeem.RedeemTokensFlowHandler.call(RedeemTokensFlowHandler.kt:22) ~[?:?] at net.corda.node.services.statemachine.FlowStateMachineImpl.subFlow(FlowStateMachineImpl.kt:329) ~[corda-node-4.1.jar:?] at net.corda.core.flows.FlowLogic.subFlow(FlowLogic.kt:314) ~[corda-core-4.1.jar:?] at com.r3.corda.lib.tokens.workflows.flows.rpc.RedeemFungibleTokensHandler.call(RedeemTokens.kt:35) ~[?:?] at com.r3.corda.lib.tokens.workflows.flows.rpc.RedeemFungibleTokensHandler.call(RedeemTokens.kt:33) ~[?:?] at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:269) ~[corda-node-4.1.jar:?] at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:45) ~[corda-node-4.1.jar:?] at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1092) ~[quasar-core-0.7.10-jdk8.jar:0.7.10] at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:788) ~[quasar-core-0.7.10-jdk8.jar:0.7.10] at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) ~[quasar-core-0.7.10-jdk8.jar:0.7.10] at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) ~[quasar-core-0.7.10-jdk8.jar:0.7.10] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_212] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_212] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[?:1.8.0_212] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[?:1.8.0_212] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_212] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_212] at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$1$thread$1.run(AffinityExecutor.kt:63) ~[corda-node-4.1.jar:?] Caused by: java.io.NotSerializableException: Described type with descriptor net.corda:vlc3i8lJnO7K1i2g0g0+aA== was expected to be of type interface java.util.List but was class com.r3.corda.lib.tokens.workflows.internal.flows.finality.TransactionRole at net.corda.serialization.internal.amqp.DeserializationInput.des(DeserializationInput.kt:102) ~[corda-serialization-4.1.jar:?] at net.corda.serialization.internal.amqp.DeserializationInput.deserialize(DeserializationInput.kt:119) ~[corda-serialization-4.1.jar:?] at net.corda.serialization.internal.amqp.AbstractAMQPSerializationScheme.deserialize(AMQPSerializationScheme.kt:225) ~[corda-serialization-4.1.jar:?] at net.corda.serialization.internal.SerializationFactoryImpl$deserialize$1$1.invoke(SerializationScheme.kt:105) ~[corda-serialization-4.1.jar:?] at net.corda.core.serialization.SerializationFactory.withCurrentContext(SerializationAPI.kt:71) ~[corda-core-4.1.jar:?] at net.corda.serialization.internal.SerializationFactoryImpl$deserialize$1.invoke(SerializationScheme.kt:105) ~[corda-serialization-4.1.jar:?] at net.corda.serialization.internal.SerializationFactoryImpl$deserialize$1.invoke(SerializationScheme.kt:73) ~[corda-serialization-4.1.jar:?] at net.corda.core.serialization.SerializationFactory.asCurrent(SerializationAPI.kt:85) ~[corda-core-4.1.jar:?] at net.corda.serialization.internal.SerializationFactoryImpl.deserialize(SerializationScheme.kt:105) ~[corda-serialization-4.1.jar:?] at net.corda.core.internal.InternalUtils.checkPayloadIs(InternalUtils.kt:516) ~[corda-core-4.1.jar:?] ... 25 more

PartyB Node from which redemption is being requested: {actor_id=internalShell, actor_owning_identity=O=PartyB, L=New York, C=US, actor_store_id=NODE_CONFIG, fiber-id=10000002, flow-id=68dceb19-d589-4eea-a0dd-1a9802b2cb19, invocation_id=7fce675c-c55d-4fff-8550-c469f8ea1f8a, invocation_timestamp=2019-07-10T13:59:55.269Z, origin=internalShell, session_id=5a98a18e-6aa4-4eb7-b3db-2a2ca841c2ec, session_timestamp=2019-07-10T13:59:54.977Z, thread-id=224, tx_id=C37D91942BCA1AC7F991DB17920FD35F26F2426721FCFCBAB7257B76F6BBA3CD} [WARN ] 2019-07-10T13:59:58,272Z [Node thread-1] interceptors.DumpHistoryOnErrorInterceptor.executeTransition - Flow [68dceb19-d589-4eea-a0dd-1a9802b2cb19] error [errorCode=1sprsib, moreInformationAt=https://errors.corda.net/OS/4.1/1sprsib] {actor_id=internalShell, actor_owning_identity=O=PartyB, L=New York, C=US, actor_store_id=NODE_CONFIG, fiber-id=10000002, flow-id=68dceb19-d589-4eea-a0dd-1a9802b2cb19, invocation_id=7fce675c-c55d-4fff-8550-c469f8ea1f8a, invocation_timestamp=2019-07-10T13:59:55.269Z, origin=internalShell, session_id=5a98a18e-6aa4-4eb7-b3db-2a2ca841c2ec, session_timestamp=2019-07-10T13:59:54.977Z, thread-id=224, tx_id=C37D91942BCA1AC7F991DB17920FD35F26F2426721FCFCBAB7257B76F6BBA3CD} net.corda.core.flows.UnexpectedFlowEndException: O=Observer, L=New York, C=US has finished prematurely and we're trying to send them the finalised transaction. Did they forget to call ReceiveFinalityFlow? (Counter-flow errored)

Withdraw flow:

class WithdrawToken(val currency: String, val amount: Long, val issuer: Party, val observer: Party) : FlowLogic<SignedTransaction>() { override val progressTracker = ProgressTracker() @Suspendable override fun call(): SignedTransaction { val token = FiatCurrency.getInstance(currency) // Starts a new flow session. return subFlow(RedeemFungibleTokens(amount of token, issuer, listOf(observer))) } }

chrisciszak commented 5 years ago

Is there anything else I could provide to help you with this issue?

kasiastreich commented 5 years ago

Hi Chris, I will take a look at this issue, and will let you know if I need any more info. Thank you for raising!

kasiastreich commented 5 years ago

@chrisciszak quick heads up, I reproduced the error fix is on the way

kasiastreich commented 5 years ago

https://github.com/corda/token-sdk/pull/121 should fix the issue