系统链码也与用户链码相同。这些链码内置于peer节点中。
Hyperledger Fabric 中提供了以下系统链代码:
- LSCC
- ESCC
- VSCC
- CSCC
- QSCC
1、LSCC: Lifecycle System Chaincode
This system chaincode is used for managing the lifecycle of chaincode. It is used for install, instantiate and update chaincode. When we install chaincode, the process goes through LSCC
2、ESCC: Endorsement System Chaincode
This system chaincode is used to endorse the transaction by digitally signing the response.
The client sends the transaction proposal to invoke chaincode function at the endorsement phase. client sign proposal with his credential and send to endorsement peers. First endorsing peer simulate transaction and verify if the client is authorized to invoke transaction on the channel. The endorsement peer executes the chaincode and creates a read/write(R/W) set. Transaction result includes response value, read set and write set. Then endorsement peer call ESCC and sign this transaction response with peer identity and send back to client.
3、VSCC: Validation System Chaincode
This is used to validate the transaction against its endorsement policy.
A Validation system chaincode evaluates endorsements in the transaction against the endorsement policy specified for the chaincode. If the endorsement policy is not satisfied, then that transaction is marked invalid.
When all peers get a block from the orderer, first they verify orderer's signature on the block. Every block is decoded and all the transaction goes through VSCC before performing MVCC validation. VSCC validates endorsements in the transaction against endorsement policy specified for chaincode. If the endorsement policy fails to satisfy, then the transaction is marked as invalid.
Note: MVCC - Multiversion Concurrency Control — It ensures that the version of keys read by transaction during the endorsement phase is the same as the current state in a local ledger at commit time. It is performed on all valid transactions in the block which is validated by VSCC. If the read set version does not match, the transaction is marked as invalid. MVCC is not chaincode, it's a mechanism to avoid the double-spending problem in Hyperledger fabric
4、CSCC: Configuration system Chaincode
This chaincode is used to manage channel configuration. When we create a channel, update channel, the process goes through the configuration system chaincode. Actually it validates the channel creation/updation.
5、QSCC: Query System Chaincode
This Chaincode runs in all peer and provide ledger API like getTransactionByTransactionID, getBlockByBlockNumber, GetBlockByTxID, GetChainInfo, GetBlockByTxID.
Hope this article will help you. It's basic information about the system chaincodes.