首页 > 解决方案 > Corda 在验证期间从哪里加载附件文件?

问题描述

在为新提议的事务收集签名时,CordaOverlappingAttachmentsException由于命名空间冲突而抛出了一个错误。错误消息似乎是正确的,因为node_attachments表中有两个附件包含相同的合同命名空间。

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:?]

Corda 在验证期间从哪里加载附件文件?我的印象是 Corda 只会从部署到节点cordapps文件夹的 cordapps 中加载验证合同,而不是尝试使用保存在node_attachments表中的合同。

如果 Corda 确实从节点库加载了合约,那么它是否遵循任何时候部署新的合约 cordapp 时它应该有一个唯一的包命名空间?

作为参考,此错误发生在测试 cordapp 升级到 Corda 4.3 的过程中。

标签: corda

解决方案


事实证明,这是由 Corda 3.3 中的合约哈希约束与 Corda 4.3 中的新合约签名约束之间的冲突引起的。为防止此错误,必须在节点上禁用哈希约束。

根据文档,节点必须使用此 JVM 选项启动:-Dnet.corda.node.disableHashConstraints="true"

https://docs.corda.net/docs/corda-os/4.3/api-contract-constraints.html#hash-constrained-states-in-private-networks

来自升级指南:“升级 CorDapp 以使用 Corda 4 签名约束并使用旧约束类型发布的分类帐上的现有状态(例如,使用哈希或 CZ 白名单约束发布的 Corda 3.x 状态)。”

https://docs.corda.net/docs/corda-os/4.3/app-upgrade-notes.html#step-9-learn-about-signature-constraints-and-jar-signing


推荐阅读