guillaume
guillaume

Reputation: 244

In Hyperledger Fabric, can we enforce transaction to be validated by a legacy/off-chain system?

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?

Upvotes: 1

Views: 390

Answers (2)

Artem Barger
Artem Barger

Reputation: 41232

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.

Upvotes: 1

user2009750
user2009750

Reputation: 3197

In my opinion the Endorsement Policy validates the World State across all endorsement peers so that peers of all organizations agree on the world state.

What you are referring to is not endorsement policy but rather a logic within the Smart Contract. It should be possible in any chaincode implementation but if you are using Hyperledger Composer for your chaincode implemenation then here from their documentation it says you can:

The Runtime API is the available API to all transaction functions. It allows access to APIs to - build and issue queries - emit events - get registries of all types - get the current participant - get the serializer to create resources from JavaScript objects - post HTTP REST calls

Based on the last part post HTTP REST calls you should be able to logically reject any transaction'

Reference

Upvotes: 0

Related Questions