github.com/yacovm/fabric@v2.0.0-alpha.0.20191128145320-c5d4087dc723+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 from the Fabric 2.0 Alpha, governance for
    37  chaincodes is fully decentralized: multiple organizations can use the Fabric
    38  Chaincode Lifecycle to come to agreement on the parameters of a chaincode,
    39  such as the chaincode endorsement policy, before the chaincode is used to
    40  interact with the ledger.
    41  
    42  The new model offers several improvements over the previous lifecycle:
    43  
    44  * **Multiple organizations must agree to the parameters of a chaincode:** In
    45    the release 1.x versions of Fabric, one organization had the ability to set
    46    parameters of a chaincode (for instance the endorsement policy) for all other
    47    channel members. The new Fabric chaincode lifecycle is more flexible since
    48    it supports both centralized trust models (such as that of the previous
    49    lifecycle model) as well as decentralized models requiring a sufficient number
    50    of organizations to agree on an endorsement policy before it goes into effect.
    51  
    52  * **Safer chaincode upgrade process:** In the previous chaincode lifecycle,
    53    the upgrade transaction could be issued by a single organization, creating a
    54    risk for a channel member that had not yet installed the new chaincode. The
    55    new model allows for a chaincode to be upgraded only after a sufficient
    56    number of organizations have approved the upgrade.
    57  
    58  * **Easier endorsement policy updates:** Fabric lifecycle allows you to change
    59    an endorsement policy without having to repackage or reinstall the chaincode.
    60    Users can also take advantage of a new default policy that requires endorsement
    61    from a majority of members on the channel. This policy is updated automatically
    62    when organizations are added or removed from the channel.
    63  
    64  * **Inspectable chaincode packages:** The Fabric lifecycle packages chaincode in
    65    easily readable tar files. This makes it easier to inspect the chaincode
    66    package and coordinate installation across multiple organizations.
    67  
    68  * **Start multiple chaincodes on a channel using one package:** The previous
    69    lifecycle defined each chaincode on the channel using a name and version that
    70    was specified when the chaincode package was installed. You can now use a
    71    single chaincode package and deploy it multiple times with different names
    72    on the same or different channel.
    73  
    74  To learn how more about the new Fabric Lifecycle, visit :doc:`chaincode4noah`.
    75  
    76  .. note:: The new Fabric chaincode lifecycle in the v2.0 Alpha release is not
    77            yet feature complete. Specifically, be aware of the following
    78            limitations in the Alpha release:
    79  
    80            - CouchDB indexes are not yet supported
    81            - Chaincodes defined with the new lifecycle are not yet discoverable
    82              via service discovery
    83  
    84            These limitations will be resolved after the Alpha release. To use the
    85            old lifecycle model to install and instantiate a chaincode, visit the
    86            v1.4 version of the `Chaincode for Operators tutorial <https://hyperledger-fabric.readthedocs.io/en/release-1.4/chaincode4noah.html>`_
    87  
    88  You can use the Fabric chaincode lifecycle by creating a new channel and setting
    89  the channel capabilities to V2_0. You will not be able to use the old lifecycle
    90  to install, instantiate, or update a chaincode on a channels with V2_0 capabilities
    91  enabled. However, you can still invoke chaincode installed using the previous
    92  lifecycle model after you enable V2_0 capabilities. Migration from the previous
    93  lifecycle to the new lifecycle is not supported for the Fabric v2.0 Alpha.
    94  
    95  .. Licensed under Creative Commons Attribution 4.0 International License
    96     https://creativecommons.org/licenses/by/4.0/