Deep Exploration of blockchain/smart contracts that support multiple languages (9)

Source: Internet
Author: User

System chain codes include:

LSCC (Lifecycle System Chaincode) lifecycle management Systems chain Code main function: Manage the chain code deployed on the endorsement node, not the whole life cycle management. CSCC (configuration system Chaincode) Configure management system chain Code key Features: Manage configuration information on the billing node QSCC (Query System chaincode) Query management system chain code main functions: To provide query accounting node ledger data, including block and transaction data, blockchain information, such as ESCC (endorsement system Chaincode) trading endorsement Systems chain Code main functions: The result of the transaction structure conversion and signature endorsement VSCC ( Validation system Chaincode) transaction Verification Systems Link code main functions: Block and transaction verification prior to accounting

ESCC and VSCC have default implementations, and new ESCC and VSCC can be implemented according to functional requirements.
One. Overview of smart contracts and life cycle management of chain codes

"1" Chain code Source: But through the definition of Chaincodedeploymentspec/cds, CDs according to code and some other attributes (name/version, etc.) to define the chain code.

"2" Instantiation Policy: (optional)

"3" Chain code signature

The signature of a chain code achieves the following 3 goals

"1" indicates who created the chain code

"2" allows verification of content in the chain code package

"3" can detect if the chain code package has been tampered with

The instantiation policy of the chain Code verifies the identity of the chain Code owner, and verifies that the source/instantiation policy of the chained code submitted is valid.

(a) Chain code creation--Two ways

"1" Multiple owners:

Requires multiple owners to sign the chain code, first create a chain code package Signedchaincode Deploymentspec, and then send to multiple owners to sign

"2" single owner: only the node that installs the chain code signs the chain code

// Create a signed chain Code pack 0 " and (' orga.admin ') " Ccpack.  out


-S: Generates a chain code with multiple owner signatures, rather than simply creating a chaincodedeploymentspec without a signature. If the-s option is specified, the-s option also needs to be specified when the other owner is signing. Otherwise, the chained package Signedchaincodedeploymentspec created will only add an instantiation policy on chaincodedeploymentspec basis and will not contain the owner's signature.

-S: The package can be signed by the MSP (defined by the Localmspid attribute value in Core.yaml). -S is optional, and if a package is created without a signature, the other owner cannot sign it by using the Signpackage command.

-I: Specifies the instantiation policy for the chain code. It indicates which identities can be instantiated on the chain code. In the example above. Only Orga administrators are allowed to instantiate the chain code. If no policy is provided, the system will use the default policy. This policy only allows the administrator of the peer node MSP to instantiate the chain code.

(ii) The signature of the chain code

The chain code is signed when it is created, and the signature process can be offline by other owners to verify the signature and continue signing.

The chain code SIGNEDCHAINCODEDEPLOYMENTSPEC is the structure that encapsulates the chaincodedeploymentspec, which mainly increases the instantiation policy and the owner's signature. Defined as follows:

Type Signedchaincodedeploymentspec struct{

Chaincodedeploymentspec byte array after serial number

Easy to meet the endorsement strategy can be.

9.2.3 request processing for an endorsement node receiving application

The application initiates the request via the Grpc interface, with the following command:

Processproposal (CTX context. Context, in *signedproposal,opts ... grpc. Calloption)

When the endorsement node receives the request, it checks whether it has permission to commit the transaction, whether it is a duplicate transaction, etc. The real execution process is done in the chain code, and ESCC finally endorses the result of execution.

Any exception in the middle will terminate the subsequent execution, and the execution result is returned to the application.

Chain code call time series diagram;

The trading simulator runs as shown:


The common chain code, the system chain code and the endorsement node establish different connections in the diagram.

Ordinary chain code is established GRPC connection, the system chain code is established by the Golang channel connection. On the same connection, there are 2 chain code calls on the operation data respectively.

The finite state machine on the side of the endorsement node records the contextual information when the different trade numbers are called, obtains the contextual information from the trading context mapping table according to the trade number, and uses the trading simulator to generate the results of the simulation execution.

A mirror with the same name does not duplicate the build. This is easy to do as long as the organization and the chain Code name and version are the same.

9.3.2 Configuration management System chain code

The configuration management system chain code (CSCC) is the full name of the configuration system Chaincode, and the primary function is to manage the provisioning information on the billing node.

1. Accounting node Join chain

The chaincodeinput of the proposal request for the accounting node join chain is no longer nested in multiple layers. The structure is as follows:

Deep Exploration of blockchain/smart contracts that support multiple languages (9)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.