1
votes

In relation to this post: Corda - java.lang.IllegalArgumentException being thrown from a validating notary

I've identified a case in Corda where states sometimes need to store a custom data type, however validating transactions using these states fails when using a validating notary.

Consider the following types to be implemented in the same package, in the same jar file:

Example Custom Type

package com.example.statescontracts

@CordaSerializable
data class Foo(
    val bar: Int, 
    val baz: String
)

Example State

package com.example.statescontracts

data class FooState(
    override val linearId: UniqueIdentifier,
    val obligor: AbstractParty,
    val obligee: AbstractParty,
    val foos: Set<Foo>
) : LinearState {
    override val participants get() = listOf(obligor, obligee)
}

Issuing a new FooState instance to the ledger probably isn't affected as it's not consuming a previous FooState instance, but subsequent consumption of FooState instances seem to fail for validating notaries.

Exception

java.lang.IllegalArgumentException: Not a valid Java name: java.util.Set<com.example.statescontracts.Foo>

Assumptions

Validation can occur for all participants of the state who have the states/contracts JAR file, and therefore can access the Foo type, however this doesn't work for the notary because it doesn't have a copy of the states/contracts JAR file locally.

As I understand it, the states/contracts JAR file should be kept small as it's attached to the transaction when proposed, therefore validating notaries should be able to validate using classes found in the JAR attached to the transaction.

Question

Can anyone verify whether my assumptions are correct, and if so, why this issue occurs for validating notaries, and how to correct this issue?

2

2 Answers

1
votes

As of Corda 3, validating notaries need the states/contracts JAR file for each transaction they are notarising.

1
votes

As described in the tech white paper, the intended end design is that the contract JARs are taken from attachments and run inside the deterministic JVM, where they're sandboxed and resource monitored.

A standalone DJVM preview is shipping in Corda 4, but is not integrated. We will continue to work on this over time, which will allow nodes that don't have the contracts JAR to validate transactions. For now, validating notaries do need to have every version of every app they may encounter installed. Non-validating notaries don't suffer this problem.