Talking about the function and use of plug-ins in China Mobile

China Mobile Chain is a China Mobile blockchain service platform built on the premise of meeting the needs of my country's informatization supervision and compliance and controllability. It allows the use of plugins to extend its functionality for a variety of different usage scenarios.

What is a mid-shift chain plug-in? If China Mobile Chain is compared to an operating system, then the plug-in is analogous to the software on the operating system. The software expands the functions of the operating system through installation, restart, etc. Similarly, the China Mobile Chain plug-in is also enabled through configuration and loading. , to expand the chain shift function.

01

Features

What are the commonly used plug-ins for China Mobile? Let's take a version of China Mobile as an example to introduce some plug-ins and their specific functions:

1. Chain plug-in: This is a chain processing plug-in, which carries the basic functions of the chain node program interacting with the blockchain, including reading basic information of the local irreversible blockchain, setting local chain checkpoints, setting local chain parameters, and setting reversible Block database parameters, set account black/white list, set smart contract black/white list, reload blockchain initial state file, and delete, rewrite, replace local blockchain data (including start, stop, etc.).

2. chain_api plug-in: depends on the chain plug-in, which provides interface services related to external call chain operations.

3.net plug-in: This is a P2P network plug-in, which carries the relevant functions of the TCP/IP layer in the P2P network of the chain system, including establishing handshake and interconnection between nodes; monitoring, sending, and receiving new transaction requests; monitoring, sending, and receiving New block request; verify the legitimacy of received data.

4. net_api plug-in: depends on the net plug-in, which provides interface services for external calls and network-related operations.

5. http plug-in: This is a network HTTP plug-in, which carries the relevant functions of the HTTP layer in the P2P network of the chain system, including monitoring, sending, and receiving new transaction requests; verifying the legitimacy of received data.

6. Producer plug-in: This is a functional plug-in of the block production node, and its functions include producing and packaging new block data; signing new blocks; verifying received blocks, including block header legality, signature legality and transaction legality sex.

7. producer_api plug-in: depends on the producer plug-in, which provides interface services related to external calls and block production node functions.

8. The blockvault_client plugin: This plugin is a new addition to the current version, that is, the blockvault function has been added from the current version, which mainly enables the blockchain to implement industry-standard disaster recovery to maximize the uptime of producers. This plugin allows block producers to be deployed as a cluster of two or more nodes of a single logical producer. If one of the nodes fails, the other nodes in the cluster will continue to operate, thus satisfying certain guarantees that the producer will continue to operate with minimal service interruption.

9. http_client plug-in: Defines the client plug-in that the China Mobile Chain network HTTP layer responds to requests and performs corresponding security verification.

10. resource_monitor plug-in: used to monitor the resource usage of the node, and provide statistical information of resource usage through the API interface, which is convenient for developers to analyze and tune.

11. History plug-in: It defines a plug-in for querying all historical transaction records of a specified public key in a specified account.

12. History_api plug-in: expose the function of history to the RPC API interface managed by the http plug-in, and provide read-only access to blockchain data; because this plug-in consumes a lot of server resources, it has been deprecated in the current version, and developers It can be replaced by state_history plug-in or trace_api plug-in.

13. state_history plug-in: This plug-in captures the historical data of the blockchain state, also known as the "state history plug-in".

14.login plug-in: depends on the http plug-in, this plug-in uses HTTP Basic Authentication (HTTP Basic Authentication) for user authentication.

15.db_size_api plug-in: This plug-in provides interface services related to external calls and data.

16.trace_api plug-in: depends on the chain plug-in and http plug-in, this plug-in provides some interfaces that can be used to obtain and analyze node operations, such as obtaining all operations in the blockchain, obtaining transaction execution tracking results, and so on.

Through the above introduction, you can understand some of the plug-ins and their functions of China Mobile Chain. Developers can choose plug-ins according to their needs. The following two examples illustrate the opening and closing of plug-ins.

02

Instructions for use

It is very convenient to open the China Mobile Chain plug-in. In the configuration file, configure the plug-in in the format of "cmeos.load("plug-in name",{"related parameters"});" and the node will read the configuration file for initialization when it starts. The configured plug-in will be loaded during the process, and the plug-in function will be enabled normally after the initialization is completed. Below is an example of enabling the plugin.

Example 1, suppose we need to start a production node and enable six plug-ins including http, net, chain, chain_api, producer, and producer_api. These plug-ins include functions such as network, chain processing and its interface services, production nodes and their interface services, etc. Add these plugins in the configuration file and configure the corresponding parameters, and then start the node. The configuration is as follows:

As shown in the figure above, in the configuration file, enable http, net, chain, chain_api, producer, producer_api and other plug-ins through the "cmeos.load("plug-in name",{"related parameters"});" format, and set the plug-ins corresponding parameters.

It is also convenient to close the plug-in of China Mobile Chain. It is to remove the related configuration of the plug-in in the configuration file and restart the node, because the restart will read the configuration file again for initialization, so that the unconfigured plug-in will no longer be enabled. Below is an example of a disabled plugin.

Example 2, assuming that eosio no longer produces blocks as a producer, we can transform the eosio production node into a synchronization node (that is, only synchronize blocks from other production nodes, and not produce blocks itself), that is, move in the configuration file Remove the producer and producer_api plug-ins, and then restart the node, as shown in the following figure:

As shown in the figure above, in this configuration file, the producer and producer_api plug-ins and their related parameters are removed. After restarting the node, the node no longer has the function of producing blocks.

03

end

This article introduces some common plugin functions and provides two sample configurations to demonstrate how to enable and disable plugins.

It can be seen that the flexibility of China Mobile’s plug-in mechanism provides developers with a very high degree of freedom. Developers can choose and combine different plug-ins to apply to different scenarios.

04

References

[1] BSN open alliance chain:

https://opb.bsnbase.com/main/index

[2] GitHub source code warehouse of EOSIO:

https://github.com/EOSIO/eos/tree/v2.1.0/plugins

-END-

Guess you like

Origin blog.csdn.net/BSN_yanxishe/article/details/131243699