Aydin
Aydin

Reputation: 149

System chaincode vs user chaincode

It the hyperledger documentation, it's stated that when implementing some features is difficult or impossible then we use system chaincode to implement those features.

But, user chaincode uses "Go" which is Turing-complete language. So, it seems to me, everything can be implemented on it (unless its cost is prohibitively high but this is not defined anywhere in hyperledger documentation).

Question 1: What kind of operations is hard or impossible to implement in user chaincode?

Question 2: When do we use system chaincode?

Upvotes: 1

Views: 286

Answers (1)

yacovm
yacovm

Reputation: 5140

Question 1: What kind of operations is hard or impossible to implement in user chaincode?

Operations that need access to native peer services like its communication layer, its Membership Service Provider (MSP) service, etc. But also operations like computing a pre-image of a 1-way function, or operations that decide whether a given code stops on a given input.

Question 2: When do we use system chaincode? In 2 types of cases:

  1. When you want your chaincode to be run inside the peer, i.e because of performance (user chaincode does lots of gRPC round trips)
  2. When you want your chaincode to be able to access all types of services the peer can only provide via code imports and code references, and the shim API cannot provide them, such as communication layer, MSP layer, and others.

Upvotes: 2

Related Questions