github.com/kaituanwang/hyperledger@v2.0.1+incompatible/docs/source/chaincode.rst (about)

     1  Chaincode Tutorials
     2  ===================
     3  
     4  What is Chaincode?
     5  ------------------
     6  
     7  Chaincode is a program, written in `Go <https://golang.org>`_, `node.js <https://nodejs.org>`_,
     8  or `Java <https://java.com/en/>`_ that implements a prescribed interface.
     9  Chaincode runs in a secured Docker container isolated from the endorsing peer
    10  process. Chaincode initializes and manages ledger state through transactions
    11  submitted by applications.
    12  
    13  A chaincode typically handles business logic agreed to by members of the
    14  network, so it may be considered as a "smart contract". State created by a
    15  chaincode is scoped exclusively to that chaincode and can't be accessed
    16  directly by another chaincode. However, within the same network, given
    17  the appropriate permission a chaincode may invoke another chaincode to
    18  access its state.
    19  
    20  Two Personas
    21  ------------
    22  
    23  We offer two different perspectives on chaincode. One, from the perspective of
    24  an application developer developing a blockchain application/solution
    25  entitled :doc:`chaincode4ade`, and the other, :doc:`chaincode4noah` oriented
    26  to the blockchain network operator who is responsible for managing a blockchain
    27  network, and who would leverage the Hyperledger Fabric API to install and govern
    28  chaincode, but would likely not be involved in the development of a chaincode
    29  application.
    30  
    31  Fabric Chaincode Lifecycle
    32  --------------------------
    33  
    34  The Fabric Chaincode Lifecycle is responsible for managing the installation
    35  of chaincodes and the definition of their parameters before a chaincode is
    36  used on a channel. Starting with Fabric 2.0, governance for chaincodes is fully
    37  decentralized: multiple organizations can use the Fabric Chaincode Lifecycle to
    38  come to agreement on the parameters of a chaincode, such as the chaincode
    39  endorsement policy, before the chaincode is used to interact with the ledger.
    40  
    41  The new model offers several improvements over the previous lifecycle:
    42  
    43  * **Multiple organizations must agree to the parameters of a chaincode:** In
    44    the release 1.x versions of Fabric, one organization had the ability to set
    45    parameters of a chaincode (for instance the endorsement policy) for all other
    46    channel members. The new Fabric chaincode lifecycle is more flexible since
    47    it supports both centralized trust models (such as that of the previous
    48    lifecycle model) as well as decentralized models requiring a sufficient number
    49    of organizations to agree on an endorsement policy before it goes into effect.
    50  
    51  * **Safer chaincode upgrade process:** In the previous chaincode lifecycle,
    52    the upgrade transaction could be issued by a single organization, creating a
    53    risk for a channel member that had not yet installed the new chaincode. The
    54    new model allows for a chaincode to be upgraded only after a sufficient
    55    number of organizations have approved the upgrade.
    56  
    57  * **Easier endorsement policy updates:** Fabric lifecycle allows you to change
    58    an endorsement policy without having to repackage or reinstall the chaincode.
    59    Users can also take advantage of a new default policy that requires endorsement
    60    from a majority of members on the channel. This policy is updated automatically
    61    when organizations are added or removed from the channel.
    62  
    63  * **Inspectable chaincode packages:** The Fabric lifecycle packages chaincode in
    64    easily readable tar files. This makes it easier to inspect the chaincode
    65    package and coordinate installation across multiple organizations.
    66  
    67  * **Start multiple chaincodes on a channel using one package:** The previous
    68    lifecycle defined each chaincode on the channel using a name and version that
    69    was specified when the chaincode package was installed. You can now use a
    70    single chaincode package and deploy it multiple times with different names
    71    on the same or different channel.
    72  
    73  To learn how more about the new Fabric Lifecycle, visit :doc:`chaincode4noah`.
    74  
    75  You can use the Fabric chaincode lifecycle by creating a new channel and setting
    76  the channel capabilities to V2_0. You will not be able to use the old lifecycle
    77  to install, instantiate, or update a chaincode on channels with V2_0 capabilities
    78  enabled. However, you can still invoke chaincode installed using the previous
    79  lifecycle model after you enable V2_0 capabilities.
    80  
    81  .. Licensed under Creative Commons Attribution 4.0 International License
    82     https://creativecommons.org/licenses/by/4.0/