在Hyperledger Fabric中,我们是否可以强制执行要由遗留/链下系统进行验证的交易? [英] In Hyperledger Fabric, can we enforce transaction to be validated by a legacy/off-chain system?

查看:63
本文介绍了在Hyperledger Fabric中,我们是否可以强制执行要由遗留/链下系统进行验证的交易?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与许多区块链解决方案(例如:以太坊,科尔达)不同,Fabric的背书架构意味着智能合约不必是确定性的和沙盒化的:唯一重要的是背书人同意R/W设置. /p>

来自解决方案

如果验证逻辑很复杂和/或依赖于World State之外的数据,是否可以调用例如WebService来执行它?

从技术上说,可以提供VSCC(验证系统链码)的自定义实现,但我敦促您不要这样做,因为这可能会导致不确定的结果.

例如,您有一个外部Web服务,并且有两个对等方根据此服务验证交易,如果由于某种原因peer1将不能访问Web服务而peer2可以,则验证结果会有所不同.因此,您应该非常小心,并避免在进行验证时调用外部系统,或者考虑改为将外部Web服务作为链码执行流程的一部分.

另外:假设链代码策略强制组织Org1认可所有事务,那么我们应该能够编写一个链代码来检查执行上下文,并且仅在验证Web服务由Org1执行并且拒绝交易或继续进行,具体取决于WS调用的结果.正确吗?

默认的验证系统链码会确保确保满足背书策略,因此在您的示例中,如果事务未获Org1背书,则该交易将失效.

Unlike many Blockchain solutions (eg: Ethereum, Corda), Fabric's endorsement architecture means that smart contracts don't have to be deterministic and sandboxed: the only thing that matters is that the endorsers agree on the R/W set.

From this SO answer, it is possible from the chaincode execution to communicate to the outside world.

If a validation logic is complex and/or depends on data outside the World State, is it possible to call for example a WebService to perform it?

Additionally: Suppose a chaincode policy enforces organization Org1 to endorse all transactions, then we should be able to write a chaincode that checks the execution context and only call the validation Web-Service if it is executed by Org1 and reject the transaction or proceed depending on the result of the WS call. Is that correct?

解决方案

If a validation logic is complex and/or depends on data outside the World State, is it possible to call for example a WebService to perform it?

While technically it's possible to provide custom implementation of the VSCC (Validation System Chaincode), I'd urge you not to do it, since that might lead to the non-deterministic results.

For instance you have your external web service and two peers which validates transaction against this service if for some reason peer1 won't be able to reach web service while peer2 will do, results of validation will differ. Therefore you should be very careful and avoid if possible to call external system while doing validation or consider to call your external web service as part of chaincode execution flow instead.

Additionally: Suppose a chaincode policy enforces organization Org1 to endorse all transactions, then we should be able to write a chaincode that checks the execution context and only call the validation Web-Service if it is executed by Org1 and reject the transaction or proceed depending on the result of the WS call. Is that correct?

The default validation system chaincode taking care to ensure whenever endorsement policy is satisfied, so in your example if transaction is not endorsed by Org1 it will be invalidated.

这篇关于在Hyperledger Fabric中,我们是否可以强制执行要由遗留/链下系统进行验证的交易?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆