2

I just started learning about Hyperledger Fabric, and I was wondering is there any way to apply business logic to the endorsement and transaction commitment process?

For example, if the endorsement policy is set to AND('Org1.member', 'Org2.member') could I somehow define what logic does the Org1.member execute to sign a transaction as valid? And could that logic be based on some State object value? (like object.NumberProp > 5)

I came around the Endorsement and Validation plugins article but I don't fully understand if that would server for that purpose or not.

Sorry for any misunderstanding I may have about the technology.

siglesias
  • 33
  • 4

2 Answers2

0

Theoretically it is possible to extract the invoker mspId from within the chaincode transaction, and then perform conditional action based on the determined mspId. This is part of the getCreator API.

It sounds like what you are asking about is chaincode level access control, which is answered here: Hyperledger Fabric: implementing chaincode level access control

nkl199
  • 21
  • 3
0

In HLF 2.x the chaincode deployment model changed significantly compared to 1.4.x version. It is possible to have each org running different business logic in their chaincode to have specific validations performed at endorsement time. In HLF 1.4.x it was required that every org runs the exact same chaincode. So back to your question: You don't really need commit-time-based logic for a specific org. You can implement that specific logic in the chaincode for your organization and fail the transaction endorsement before the commit phase. This way your org may run specific business validations without exposing their internals to the other orgs on the network.

Regarding the endorsement policy: I don't recommend overwriting the endorsement policy plugin in order to implement custom logic unless there is a very strong business need for that. I would rather use the capabilities of the existing HLF chaincode endorsement process to achieve what is needed. https://hyperledger-fabric.readthedocs.io/en/latest/endorsement-policies.html

Regards, Tsvetan