Where does Corda load attachment files from during verification? - corda

When collecting signatures on a newly proposed transaction Corda threw an OverlappingAttachmentsException because of a namespace conflict. The error message appears to be correct because there are two attachments which contain the same namespace for the contract in the node_attachments table.
net.corda.core.contracts.TransactionVerificationException$OverlappingAttachmentsException:
Multiple attachments define a file at com/foo/company/<state>/api/v2/orderdetails.class., transaction: 1C1985615C0B53F228B22B2C4F05CE039CC6C577A87E3B2FC9AA2CB00ED5FC43
at net.corda.core.serialization.internal.AttachmentsClassLoader.checkAttachments(AttachmentsClassLoader.kt:272) ~[corda-core-4.3.jar:?]
at net.corda.core.serialization.internal.AttachmentsClassLoader.<init>(AttachmentsClassLoader.kt:132) ~[corda-core-4.3.jar:?]
at net.corda.core.serialization.internal.AttachmentsClassLoaderBuilder$withAttachmentsClassloaderContext$serializationContext$1.apply(AttachmentsClassLoader.kt:325) ~[corda-core-4.3.jar:?]
at net.corda.core.serialization.internal.AttachmentsClassLoaderBuilder$withAttachmentsClassloaderContext$serializationContext$1.apply(AttachmentsClassLoader.kt:298) ~[corda-core-4.3.jar:?]
at java.util.HashMap.computeIfAbsent(HashMap.java:1127) ~[?:1.8.0_212]
at java.util.Collections$SynchronizedMap.computeIfAbsent(Collections.java:2672) ~[?:1.8.0_212]
at net.corda.core.serialization.internal.AttachmentsClassLoaderBuilder.withAttachmentsClassloaderContext(AttachmentsClassLoader.kt:323) ~[corda-core-4.3.jar:?]
at net.corda.core.serialization.internal.AttachmentsClassLoaderBuilder.withAttachmentsClassloaderContext$default(AttachmentsClassLoader.kt:319) ~[corda-core-4.3.jar:?]
at net.corda.core.transactions.LedgerTransaction.internalPrepareVerify$core(LedgerTransaction.kt:146) ~[corda-core-4.3.jar:?]
at net.corda.core.transactions.LedgerTransaction.verify(LedgerTransaction.kt:136) ~[corda-core-4.3.jar:?]
at net.corda.core.flows.CollectSignaturesFlow.call(CollectSignaturesFlow.kt:103) ~[corda-core-4.3.jar:?]
at net.corda.core.flows.CollectSignaturesFlow.call(CollectSignaturesFlow.kt:67) ~[corda-core-4.3.jar:?]
Where does Corda load attachment files from during verification? I was under the impression Corda would only load contracts for validation from cordapps deployed to the node's cordapps folder directly and not attempt to use contracts saved in the node_attachments table.
If Corda does load contracts from the node vault then does it follow that the anytime a new contract cordapp is deployed that it should have a unique package namespace?
For reference this error occurred during testing of a cordapp upgrade to Corda 4.3.

This turned out to be caused by a conflict between contract hash constraints from Corda 3.3 and the new contract signature constraints from Corda 4.3. To prevent this error hash constraints have to be disabled on the node.
As per docs the node must be started with this JVM option: -Dnet.corda.node.disableHashConstraints="true"
https://docs.corda.net/docs/corda-os/4.3/api-contract-constraints.html#hash-constrained-states-in-private-networks
From the upgrade guide: "Upgrade CorDapps to use Corda 4 signature constraints and consume existing states on ledger issued with older constraint types (e.g. Corda 3.x states issued with hash or CZ whitelisted constraints)."
https://docs.corda.net/docs/corda-os/4.3/app-upgrade-notes.html#step-9-learn-about-signature-constraints-and-jar-signing

Related

Corda Network-Map is up and running, but Notary is not in whitelist

I have a Corda Infrastructure with some nodes and a (not validating) notary. They're all using a Network Map for the compatibility zone, and all the corda nodes, including the notary, download the same network-parameters file.
When executing a flow, Corda gives me an Exception because the Notary is not on the network parameters whitelist. I cannot find anything anything about that on R3 Documentation.
java.lang.IllegalStateException: Notary [O=Notary, L=Cosenza, C=IT (owningKey = DLAdtNkbnrjn6FGwzE4sCaiDS3tRgMw3KhZfA7bD3icYK1)] specified by the transaction is not on the network parameter whitelist: []
at net.corda.core.internal.TransactionUtilsKt.checkNotaryWhitelisted(TransactionUtils.kt:257) ~[corda-core-4.8.jar:?]
Note that I'm using a fixed Notary X500 Name in the Flow code instead of "preferredNotary" because it won't be found. I think it is because of the same problem.
Do I have to do something explicit to add Notary in network parameters whitelist?
Do I have to do something explicit to add Notary in network parameters whitelist?
Yeah you do. Since you are using a network-map-service your node will get its network-parameters from there.
What you'll have to do then is
delete your current network-parameters for every Node.
whitelist your Notary Node into your network-map-service
restart all your Nodes so they can retrieve the new network-parameters from the network-map-service where the new Notary is assigned as such
I don't know which network-map-service exactly you use but i assume its nms by cordite. You can read up on how to whitelist a Notary here: https://gitlab.com/cordite/network-map-service/-/blob/master/FAQ.md#14-start-the-notary-node

How to deploy multiple nodes in Corda Testnet network?

We are building a POC using Corda and Springboot web server.
Following are the versions of Corda platform, Springboot server, and other essential dependencies used for building the POC-
cordaReleaseGroup=net.corda
cordaVersion=4.0
gradlePluginsVersion=4.0.45
kotlinVersion=1.2.71
junitVersion=4.12
quasarVersion=0.7.10
spring_version = '4.3.11.RELEASE'
spring_boot_version = '2.0.2.RELEASE'
spring_boot_gradle_plugin_version = '2.1.1.RELEASE'
jvmTarget = "1.8"
log4jVersion =2.11.2
platformVersion=4
slf4jVersion=1.7.25
nettyVersion=4.1.22.Final
The CorDapp developed for POC has four nodes -
Notary Node
Provider Company Node
Consumer Company 1 Node
Consumer Company 1 Sub Contact Node
The POC is running in dev mode in our local network.
We require to test the POC in the Corda Testnet.
We went through the following documentation on Corda Testnet -
1: Join Corda TestNet
URL : https://docs.corda.net/releases/release-V4.0/corda-testnet-intro.html?highlight=joining%20corda%20testnet
2: Deploying Corda to Corda Testnet from your local environment
https://docs.corda.net/releases/release-V4.0/deploy-locally.html?highlight=deploying%20corda%20corda%20testnet%20from%20your%20local%20environment
We understood from the above documentation that we can download only one "Corda node" using one registration. Will we have to join the Corda Testnet using four different accounts in order to download four Corda nodes?
Is our understanding correct?
As per my understanding you can spin up multiple nodes with a refresh of the Testnet node installation page, or by creating a node and then clicking 'next', which should take you back to the node list and present a button to allow creation of another node.
It should provide you with a unique ONE_TIME_DOWNLOAD_KEY each time, and automatically assign you a randomised alphanumeric O (organisation) value to use within the nodes configuration file, helping the network map (and thus other nodes on the network) to distinguish your nodes individually.
Make sure you don't unintentionally run copies of the same node with the same identity, otherwise the network map will just assume there has been a change in the address of the original node and route P2P traffic to the newest instance.
Take a look at the node.conf docs to understand node configuration further:
https://docs.corda.net/corda-configuration-file.html

How do I register the worker notary nodes in a Corda Enterprise HA Cluster?

When I follow the directions in https://docs.corda.r3.com/running-a-notary-cluster/installing-the-notary-service-bootstrapper.html
I get the error shown below. This happens both when I try using just “generate_node_info” as well as the general bootstrapper command. The reason is that I already have the O=Notary name registered as the notary and its certificate is in the *.jks file in the certificates directory. What I need is to get the worker nodes registered. That does not seem to work. It expects the name to already match what is in the certificates.
[1;31m[ERROR] 17:51:20-0500 [main] internal.Node.run - Exception during node startup
[m net.corda.node.internal.ConfigurationException: The name 'O=Notary-1, L=London, C=GB' for identity doesn't match what's in the key store: O=Notary, L=London, C=GB
at net.corda.node.internal.AbstractNode.obtainIdentity(AbstractNode.kt:945) ~[corda-node-3.2.jar:?]
at net.corda.node.internal.AbstractNode.generateAndSaveNodeInfo(AbstractNode.kt:213) ~[corda-node-3.2.jar:?]
For anyone coming up to this question, it falls under the same umbrella as most Corda enterprise issues where they're so specific that you're better off contacting R3 enterprise support.
This particular question I believe is being handled by the support team so if you're using Corda Enterprise you'd be better off doing the same thing.
Best of luck and thanks.

How to use contracts in attachments

I uploaded contract jar from rpc shell. And then used the hash in the transaction builder
val txBuilder = TransactionBuilder(notary)
.addOutputState(
TransactionState(
dummyState,
"com.example.contract.SampleContract",
notary,
null,
HashAttachmentConstraint(SecureHash.parse(hashId))
)
)
.addCommand(txCommand)
On running this flow, I see the below error in the notary log:
net.corda.core.contracts.TransactionVerificationException$ContractConstraintRejection:
Contract constraints failed for com.example.contract.SampleContract,
transaction:
781CC5C14E9DC7642B3C7F12177CB79C5EADE0D7F2033F56DB6909E1F2199C42
The SecureHash of my uploaded jar is "05A2B667D5DDE42A632EF0A9810D5CE90B3F31BFF62E0539C11C9DEB0FAC2430". This is different from the one seen in the error message.
CordaRPCOps.uploadAttachment should not be used for contract JARs. Contract JARs should be added to the node by adding the JAR files to the node's cordapps folder and restarting the node. If the notary is a validating notary, they will also require a copy of the contract JAR.
CordaRPCOps.uploadAttachment should only be used for attachments containing supporting information for a transaction. These attachments are propagated automatically and are added to transactions using the TransactionBuilder.addAttachment method.

Is there any possible to update transaction using keys of notary

am trying to deploying the nodes in different machine. its working fine. But i have many doubts. controller, Notary, customer1 and customer2 are in one MachineA and customer3 and customer4 are in MachineB. if i do any transaction between customer3 and customer4 in machineB, it will generate keys in certificates folder for all nodes.I placed my notary in machineA. Is that possible to update some changes using those keys in machineA without the knowledge of nodes in machineB?
The certificates that you are generated on all the nodes when you conduct a transaction between customer3 and customer4 are development certificates that are automatically generated to allow nodes to communicate.
In a real deployment, you'd turn off development mode on each node using a devMode=false flag in each node's node.conf file. See https://docs.corda.net/corda-configuration-file.html.
You'd then have to provision each node will proper certificates by following the instructions here: https://docs.corda.net/permissioning.html. If you do not provide the proper certificates, your nodes will fail to start with an error like the following:
java.lang.IllegalArgumentException: Identity certificate not found.
Please either copy your existing identity key and certificate from
another node, or if you don't have one yet, fill out the config file
and run corda.jar --initial-registration. Read more at:
https://docs.corda.net/permissioning.html at
net.corda.node.internal.AbstractNode.validateKeystore(AbstractNode.kt:460)
~[corda-node-2.0.0.jar:?] at
net.corda.node.internal.AbstractNode.start(AbstractNode.kt:179)
~[corda-node-2.0.0.jar:?] at
net.corda.node.internal.Node.start(Node.kt:312)
~[corda-node-2.0.0.jar:?] at
net.corda.node.internal.NodeStartup.startNode(NodeStartup.kt:95)
~[corda-node-2.0.0.jar:?] at
net.corda.node.internal.NodeStartup.run(NodeStartup.kt:74)
[corda-node-2.0.0.jar:?] at net.corda.node.Corda.main(Corda.kt:11)
[corda-node-2.0.0.jar:?]

Resources