Skip to content

Commit 312eefb

Browse files
committed
[FAB-6810] Document SCC Plugins
Change-Id: I8c97c862e84d095599437c759d28bcf032192d80 Signed-off-by: Divyank Katira <Divyank.Katira@securekey.com>
1 parent a47bf65 commit 312eefb

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Business:
5555
chaincode
5656
chaincode4ade
5757
chaincode4noah
58+
systemchaincode
5859
videos
5960

6061
.. toctree::

docs/source/systemchaincode.rst

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
System Chaincode Plugins
2+
========================
3+
4+
System chaincodes are specialized chaincodes that run as part of the peer process
5+
as opposed to user chaincodes that run in separate docker containers. As
6+
such they have more access to resources in the peer and can be used for
7+
implementing features that are difficult or impossible to be implemented through
8+
user chaincodes. Examples of System Chaincodes are ESCC (Endorser System Chaincode)
9+
for endorsing proposals, QSCC (Query System Chaincode) for ledger and other
10+
fabric related queries and VSCC (Validation System Chaincode) for validating
11+
a transaction at commit time respectively.
12+
13+
Unlike a user chaincode, a system chaincode is not installed and instantiated
14+
using proposals from SDKs or CLI. It is registered and deployed by the peer at start-up.
15+
16+
System chaincodes can be linked to a peer in two ways: statically and dynamically
17+
using Go plugins. This tutorial will outline how to develop and load system chaincodes
18+
as plugins.
19+
20+
Developing Plugins
21+
------------------
22+
23+
A system chaincode is a program written in `Go <https://golang.org>`_ and loaded
24+
using the Go `plugin <https://golang.org/pkg/plugin>`_ package.
25+
26+
A plugin includes a main package with exported symbols and is built with the command
27+
``go build -buildmode=plugin``.
28+
29+
Every system chaincode must implement the `Chaincode Interface <http://godoc.org/github.com/hyperledger/fabric/core/chaincode/shim#Chaincode>`_
30+
and export a constructor method that matches the signature ``func New() shim.Chaincode`` in the main package.
31+
An example can be found in the repository at ``examples/plugin/scc``.
32+
33+
Existing chaincodes such as the QSCC can also serve as templates for certain
34+
features - such as access control - that are typically implemented through system chaincodes.
35+
The existing system chaincodes also serve as a reference for best-practices on
36+
things like logging and testing.
37+
38+
.. note:: On imported packages: the Go standard library requires that a plugin must
39+
include the same version of imported packages as the host application (fabric, in this case)
40+
41+
Configuring Plugins
42+
-------------------
43+
44+
Plugins are configured in the ``chaincode.systemPlugin`` section in *core.yaml*:
45+
46+
.. code-block:: bash
47+
48+
chaincode:
49+
systemPlugins:
50+
- enabled: true
51+
name: mysyscc
52+
path: /opt/lib/syscc.so
53+
invokableExternal: true
54+
invokableCC2CC: true
55+
56+
57+
A system chaincode must also be whitelisted in the ``chaincode.system`` section in *core.yaml*:
58+
59+
.. code-block:: bash
60+
61+
chaincode:
62+
system:
63+
mysyscc: enable
64+
65+
66+
.. Licensed under Creative Commons Attribution 4.0 International License
67+
https://creativecommons.org/licenses/by/4.0/

0 commit comments

Comments
 (0)