Disclosure of Invention
The invention aims to provide a multi-blockchain bottom layer platform nano-tube method which is used for solving the problems of insufficient multi-purpose one-chain diversity and insufficient multi-chain coexistence compatibility faced by the prior popularization of blockchain application in various places.
The invention aims to solve the technical problem of how to formulate the requirements of the adaptive interface of the bottom-layer platform of the blockchain on the premise of not changing the technical architecture of the bottom-layer platform of each blockchain, and provides a universal interaction method for data, application, events and the like of the bottom-layer platform of the multi-blockchain so as to realize unified nano-tubes of the bottom-layer platform of the multi-blockchain.
The technical scheme is that the multi-blockchain bottom layer platform nano-tube method comprises the following steps:
Step one, determining the nano-tube key point of the bottom layer platform of the block chain. Analyzing the common function of external interfaces of Software Development Kits (SDKs) of different blockchain bottom platforms, and determining the key point of the multi-blockchain bottom platform nano-tube by combining the requirements of the multi-blockchain bottom platform nano-tube from four aspects of data reading and writing, application deployment, intelligent contract calling and on-chain event monitoring;
And secondly, formulating the adaptive interface requirement of the block chain bottom layer platform. Interface specifications to be followed by the blockchain bottom platform are formulated from four aspects of data reading and writing, application deployment, intelligent contract calling and on-chain event monitoring respectively, corresponding interface function, input parameter and output parameter requirements are defined, and standards for the intercommunication of the nanotubes of the multi-blockchain bottom platform are formed;
And thirdly, adapting and reforming the external interface by the block chain bottom layer platform. Performing adaptation and reconstruction on the external interaction interface of the block chain bottom layer platform of the quasi-nanotube according to the interface specification determined in the second step, wherein the data read-write, application deployment, intelligent contract calling and on-chain event monitoring are performed on the external interaction interface;
And fourthly, auditing and deploying the block chain bottom layer platform nanotubes. Testing the connectivity of the interface adaptation transformation of the bottom layer platform of the quasi-nanotube blockchain, and performing online deployment after testing to form one of the bottom layer platforms of the blockchain nanotube platform;
And fifthly, adapting the nano tube to the multi-block chain bottom layer platform. And (3) repeating the third step and the fourth step for other blockchain bottom platforms needing nanotubes to realize the adaptive nanotubes of the multi-blockchain bottom platform.
As a preferred embodiment of the present invention, the data read-write interface specification interface functions include an acquisition block interface and an acquisition transaction interface. The input parameters of the block interface are obtained as block numbers, the output parameters are block information, the input parameters of the transaction interface are obtained as transaction numbers, and the output parameters are transaction information.
As a preferred embodiment of the present invention, the application deployment interface specification interface functions include creating an application chain interface, joining an application chain interface, and exiting an application chain interface. The method comprises the steps of creating an application link interface input parameter which is an application link configuration file and is used for requesting block chain link points to create an application link without output parameters, adding the application link interface input parameter which is an application link name and is used for adding the block chain link points into the application link without output parameters, and exiting the application link interface input parameter which is an application link name and is used for exiting the application link by the block chain link points without output parameters.
As a preferred embodiment of the present invention, the smart contract call interface specification interface functions include smart contract initialization, smart contract deployment, smart contract upgrade, smart contract deletion. The intelligent contract initialization interface input parameters are intelligent contract names and intelligent contract parameters, the deployed intelligent contracts are initialized mainly, no output parameters exist, the intelligent contract deployment interface input parameters are intelligent contract names and intelligent contract parameters, the intelligent contract deployment interface input parameters are mainly used for deploying the intelligent contracts to the blockchain nodes, no output parameters exist, the intelligent contract upgrading interface input parameters are intelligent contract names and intelligent contract parameters, the intelligent contract upgrading interface input parameters are mainly used for upgrading the intelligent contracts on the blockchain nodes, no output parameters exist, the intelligent contract deleting interface input parameters are intelligent contract names, and the intelligent contract deleting interface input parameters are mainly used for deleting the intelligent contracts on the blockchain nodes, and no output parameters exist.
As a preferred embodiment of the present invention, the on-chain event listening interface specification interface functions include registration events, event queries, event deletions. The input parameters of the event registering interface are event keys, the output parameters are event codes and are used for registering event callback and receiving event notification, the input parameters of the event inquiring interface are event codes and are used for inquiring a registered chain code event monitoring list, no output parameters are generated, and the input parameters of the event deleting interface are event codes and are used for logging off the registered chain code event monitoring, and no output parameters are generated.
The invention has the following beneficial effects:
1. establishing a data interface communication standard for the nanotube intercommunication of the multi-block-chain bottom-layer platforms by formulating the interface adaptation requirements of the block-chain bottom-layer platforms, wherein the nanotubes can be unified by adapting and reforming different block-chain bottom-layer platforms according to the interface requirements, so that the flexible selection requirements of the multi-block-chain bottom-layer platforms applied to the block chains in various fields in each place are met;
2. The adaptation and transformation of the blockchain bottom layer platform of the nanotube are realized by only carrying out core interface encapsulation such as data reading and writing, application deployment, intelligent contract calling, on-chain event monitoring and the like based on the original SDK, the permeation modification of the original blockchain bottom layer platform is not needed, the upper application service mode and the user chain habit are not changed, and the smooth migration of an independent service chain developed by adopting the original blockchain bottom layer platform is supported;
3. through carrying out the nano tube to multizone block chain bottom platform, unify the interface standard, the developer need not to write specific logic for every different block chain bottom platform, has reduced the development repeatability, has effectively reduced the technical difficulty and the cost of multizone block chain bottom platform maintenance.
Detailed Description
The following takes FISCO BCOS and XuperChain two blockchain bottom platform nanotubes as examples to further describe the technical scheme in the embodiment of the present invention in detail.
FISCO BCOS is a stable, efficient and safe blockchain bottom platform, is developed by the gold chain alliance lead of the micro-mass banks, adopts the technical architecture of alliance chains, integrates and absorbs various technologies such as distributed architecture, distributed storage, point-to-point network protocol, encryption algorithm, consensus algorithm, intelligent contract, virtual machine and the like, has the advantages of high performance, safety, controllability, rich functions and the like, is widely applied to the fields of finance, medical treatment, education, culture, social management and the like, and becomes an important blockchain bottom frame for popularization and application of blockchains in various fields. XuperChain is a blockchain bottom layer platform developed independently in hundred degrees, provides multi-component and customized development services, supports global deployment and intra-chain parallelism, provides users with the elastic payment capability of resources such as environments, calculation and storage of rapid deployment and operation of blockchain applications, is applied to multiple fields such as judicial, government affairs, education, tracing and the like, and is a blockchain operating system facing enterprise development and user use.
The embodiment adopts the invention to implement two blockchain bottom platform nanotubes FISCO BCOS and XuperChain, and the specific workflow is as shown in figure 1:
Step one, determining the nano-tube key point of the bottom layer platform of the block chain. And analyzing the common functions of external interfaces of different blockchain bottom layer platform Software Development Kits (SDKs), and determining the key points of the multi-blockchain bottom layer platform nanotubes from four aspects of data reading and writing, application deployment, intelligent contract calling and on-chain event monitoring by combining the requirements of the multi-blockchain bottom layer platform nanotubes.
The invention provides a multi-blockchain bottom layer platform nano-tube method, which is mainly considered in terms of technical compatibility and diversity, and is used for realizing the main-stream blockchain bottom layer platform adaptive nano-tube. The main stream blockchain underlying platform SDKs of FISCO BCOS, xuperChain, fabric, CITA, phoenix chain, brochain, etc. were analyzed here for main external interface functions as shown in table 1. The SDK external interface functions supported by the main stream block chain bottom layer platforms are the data read-write, application deployment, intelligent contract calling and on-chain event monitoring, and only part of the SDK external interface functions of the main stream block chain bottom layer platforms can be provided by channels, side chains and groups. From the view of the multi-block chain bottom layer platform nano-tube requirement, the data reading and writing, application deployment and intelligent contract calling are the regular operation of the block chain bottom layer platform, and as the core requirement, the on-chain event monitoring allows the application program to respond correspondingly when a specific event occurs on the block chain, so that the flexibility of the block chain bottom layer platform nano-tube can be improved. Therefore, the four functions of data reading and writing, application deployment, intelligent contract calling and on-chain event monitoring can meet the requirements of the multi-blockchain bottom layer platform nanotubes, and are determined to be the key points of the multi-blockchain bottom layer platform nanotubes.
TABLE 1
And secondly, formulating the adaptive interface requirement of the block chain bottom layer platform. Interface specifications to be followed by the blockchain bottom platform are formulated from four aspects of data reading and writing, application deployment, intelligent contract calling and on-chain event monitoring respectively, corresponding interface function, input parameter and output parameter requirements are defined, and standards for the multi-blockchain bottom platform nanotube intercommunication are formed.
As a preferred embodiment of the present invention, the interface modes of data read-write, application deployment, intelligent contract call and on-link event monitoring are defined, including interface functions, input parameters, output parameters, interface functions and parameter descriptions, as shown in table 2.
TABLE 2
The data read-write interface specification interface functions include an acquire block interface and an acquire transaction interface. The input parameters of the block interface are obtained as block numbers, the output parameters are block information, the input parameters of the transaction interface are obtained as transaction numbers, and the output parameters are transaction information. Taking XuperChain block interfaces as an example, the blockchain nanotube platform sends a communication request to a XuperChain blockchain node by calling getBlockInfo functions and carrying a block number as a parameter, after XuperChain blockchain nodes receive the request, searching locally stored blockchain data and locating the locally stored blockchain data to a specified block number, returning all information of the block if the corresponding block is found, and returning error information if the corresponding block is not found.
The application deployment interface specification interface functions include generating create application chain interfaces, join application chain interfaces, and exit application chain interfaces. The method comprises the steps of creating an application link interface input parameter which is an application link configuration file and is used for requesting block chain link points to create an application link without output parameters, adding the application link interface input parameter which is an application link name and is used for adding the block chain link points into the application link without output parameters, and exiting the application link interface input parameter which is an application link name and is used for exiting the application link by the block chain link points without output parameters. Taking creating XuperChain an application chain interface as an example, the blockchain nanotube platform sends a communication request containing an application chain configuration file to a XuperChain blockchain link point by calling a NEWAPPCHAIN function, after receiving the request, the XuperChain blockchain node analyzes the configuration file and creates a new application chain according to the configuration, after the creation is successful, the node updates the internal state, and broadcasts the event to other nodes.
The smart contract invocation interface specification interface functions include smart contract initialization, smart contract deployment, smart contract upgrade, smart contract deletion. The intelligent contract initialization interface input parameters are intelligent contract names and intelligent contract parameters, the deployed intelligent contracts are initialized mainly, no output parameters exist, the intelligent contract deployment interface input parameters are intelligent contract names and intelligent contract parameters, the intelligent contract deployment interface input parameters are mainly used for deploying the intelligent contracts to the blockchain nodes, no output parameters exist, the intelligent contract upgrading interface input parameters are intelligent contract names and intelligent contract parameters, the intelligent contract upgrading interface input parameters are mainly used for upgrading the intelligent contracts on the blockchain nodes, no output parameters exist, the intelligent contract deleting interface input parameters are intelligent contract names, and the intelligent contract deleting interface input parameters are mainly used for deleting the intelligent contracts on the blockchain nodes, and no output parameters exist. Taking XuperChain intelligent contract deployment as an example, the blockchain nanotube platform sends a communication request containing an intelligent contract name and intelligent contract information to a XuperChain blockchain node by calling a InstallChaincode function, and after the XuperChain blockchain node receives the request, the blockchain node checks whether the intelligent contract chain code is initialized or not, adds the intelligent contract chain code into a designated channel and instantiates the intelligent contract chain code.
The on-chain event listening interface specification interface functions include registration events, event queries, event deletions. The input parameters of the event registering interface are event keys, the output parameters are event codes and are used for registering event callback and receiving event notification, the input parameters of the event inquiring interface are event codes and are used for inquiring a registered chain code event monitoring list, no output parameters are generated, and the input parameters of the event deleting interface are event codes and are used for logging off the registered chain code event monitoring, and no output parameters are generated. Taking XuperChain register event interface as an example, the blockchain nanotube platform sends a communication request containing event key to XuperChain blockchain node by calling EVENTREGISTER function, xuperChain blockchain node registers an event listener after receiving the request, and returns unique event code. When an event occurs, the block link will send a notification to the caller using the event code.
And thirdly, adapting and reforming the external interface by the block chain bottom layer platform. And (3) carrying out adaptation and reconstruction on the external interaction interface of the block chain bottom layer platform of the quasi-nanotube according to the interface specification determined in the step two, wherein the data reading and writing, the application deployment, the intelligent contract calling and the on-chain event monitoring are carried out.
For the present embodiment, the blockchain bottom platform of the quasi-nanotube includes FISCO BCOS and XuperChain. The process of adapting and reforming the external interactive interface according to the interface standard defined in table 2, such as data reading and writing, application deployment, intelligent contract calling and on-chain event monitoring of FISCO BCOS is mainly described herein.
In the aspect of data read-write interface adaptation, the difference between the FISCO BCOS original interface design and the interface specification proposed by the invention needs to be correspondingly modified. FISCO BCOS the original interface provides the function of reading the block and transaction information, but the interface design is inconsistent with the interface specification required by the embodiment of the invention. Taking the modification of the block information interface as an example, the original interface FISCO BCOS only receives one block height parameter, and the embodiment obtains the block interface specification requirement and returns the block hash value. In order to enable FISCO BCOS to be managed, the original interface function GetBolckInfoByBlockHeight () of FISCO BCOS is called to obtain the block height data by converting the incoming block hash into the block height, and then the returned result is converted into the correct format according to the data read-write interface specification and output. Similarly, the acquisition transaction interface is further adapted. Through the transformation, the FISCO BCOS data read-write interface can be successfully in butt joint with the blockchain nanotube platform, so that unified management and access of data read-write are realized.
In terms of application deployment interface adaptation, the goal is to ensure that different blockchain underlying platforms can perform application deployment and management through a unified interface. This process involves translating the application deployment interface specification of the present embodiment with interfaces specific to each blockchain underlying platform to achieve a standardized deployment flow. For FISCO BCOS, the application deployment interface adaptation translates the application deployment information into group information for the FISCO BCOS underlying chain, ensuring that the application can run on the nodes of FISCO BCOS.
Specifically, FISCO BCOS application deployment interface adaptation is achieved by:
1. And creating an application chain interface, namely inputting an application chain configuration file, converting the request into a FISCO BCOS creation command for creating the application chain on the blockchain. Firstly, creating a new application chain on all nodes of each participating organization by calling a bottom newly-built application chain interface, secondly, starting an application chain of each node under each organization by using a bottom control application chain state interface and setting type=start parameters to ensure normal operation of the application chain, and finally, adding at least one administrator user for each organization by calling a bottom newly-built application chain administrator user interface to give authority for managing the application chain. This series of operations ensures successful establishment and efficient management of the application chain.
2. And (3) adding an application chain interface, namely inputting an application chain name, and converting the information into a FISCO BCOS adding command so that the blockchain node can be added into the application chain. Firstly, creating a new node by calling a new application chain interface and filling information of the new node in nodeId fields, secondly, starting an application chain state of the new node by using a control application chain state interface and setting type=start parameter and nodeId as new node information, and finally, calling a node consensus state management interface twice, setting the consensus state of the new node, setting nodeId as the new node when calling for the first time, setting reqNodeId as the consensus node of the application chain, setting nodeType as an observer, setting nodeId as the new node when calling for the second time, setting reqNodeId as the consensus node of the application chain, and changing nodeType into sealer. This series of operations ensures that the new node can successfully join the application chain and participate in the consensus process.
3. And (3) exiting the application chain interface, namely inputting the name of the application chain, converting the request into an exiting command, and allowing the block chain link point to exit the application chain. Firstly, stopping the application chain state of all nodes under each organization by calling the bottom control application chain state interface and setting type=stop parameters, secondly, calling the bottom control application chain state interface again and setting type=remove parameters to remove the application chain, and finally, notifying to delete the group account book files under each relevant node. These steps ensure thorough cleaning from the application layer to the data layer so that the group exit or delete operation is completed smoothly.
In terms of intelligent contract invocation interface adaptation, the goal is to ensure that intelligent contracts of different blockchain underlying platforms can be invoked and managed through the same interface while supporting flexible parameter configuration. FISCO BCOS the intelligent contract invocation interface adaptation content is as follows:
1. And the intelligent contract initializing interface is used for calling the bottom initializing interface, and transmitting the name of the intelligent contract and the parameters of the intelligent contract to initialize the contract. The initialization of the intelligent contract is only needed to be executed once and can be executed on any node.
2. The intelligent contract deployment interface is used for firstly compiling the contract by calling the bottom-layer contract compiling interface to ensure that the contract code is free of errors and converted into an executable format, secondly storing or updating the compiled contract by using the bottom-layer contract storing interface so that an organization where a newly added user is can call, finally calling the bottom-layer contract deployment interface to deploy the contract, packaging the intelligent contract name, the intelligent contract parameters and related codes into a standard format conforming to a FISCO BCOS bottom-layer contract deployment package, and then requesting to efficiently deploy the intelligent contract to a node of FISCO BCOS.
3. The intelligent contract upgrading interface is similar to the deployment process, firstly, the bottom contract compiling interface is called to compile contracts to ensure that contract codes are free of errors and converted into executable formats, secondly, the bottom contract saving interface is used for saving or updating the compiled contracts so that organizations where new users are located can call, and finally, the bottom contract deploying interface is called to deploy the contracts, intelligent contract names, parameters and related codes are packaged into deployment package formats which accord with FISCO BCOS standards, and therefore the intelligent contracts are deployed to nodes of FISCO BCOS efficiently. The process ensures that intelligent contracts are smoothly carried out from development to online, so that organizations where new users are located can effectively utilize and manage the contracts.
4. The intelligent contract deleting interface calls the self-destruction contract of the contract on the chain by calling selfdestruct function, which deletes the code and storage of the contract, releases network resource, and removes the intelligent contract on the block chain node.
Through the adaptation measures, the intelligent contract call interface adaptation ensures that the intelligent contract can keep consistent behaviors on the FISCO BCOS block chain bottom layer platform, meanwhile, the work of a developer is simplified, and the interoperability and portability of the cross-chain intelligent contract are improved.
In terms of on-chain event listening interface adaptation, for the FISCO BCOS native event listening mechanism, an adaptation is required to meet the interface specification defined in this embodiment. This adaptation process aims to ensure that the on-chain event listening function of the FISCO BCOS blockchain bottom-layer platform can interact under a unified interface specification, thereby realizing cross-chain event listening and management. FISCO BCOS the native supports on-chain event listening, but its interface design differs from the interface specification of this embodiment. The adaptation work mainly comprises:
1. Interface naming and parameter adjustment-the on-chain event listening interface naming of FISCO BCOS is adjusted to be in compliance with the interface specification of table 2. Meanwhile, the parameter structure is adjusted to match the definition of the parameter type in the interface specification of the present embodiment.
2. The event registration interface of FISCO BCOS needs to be able to receive event keys as input and return event encodings. The adaptation work needs to ensure that the mapping relation between the event key and the event code is correct, and the registration of the event can be completed through the interface of FISCO BCOS. When an event is triggered, the system will send event content to the registered notification address. The user needs to provide an event type (eventType), with a value of 1 representing a block event and a value of 2 representing a contract event. The contract address (contractAddress) and contract name (contractName) may be null when a block event is selected, and may not be null at the same time if a contract event is selected. In addition, the user also needs to provide a notification address (notifyUrl) to receive event notifications.
3. Event querying and deleting-ensuring that the event querying and deleting interface FISCO BCOS can be performed according to the interface specification of this embodiment, i.e. querying or deleting the corresponding on-chain event listener by event encoding.
Similarly, the same method is adopted to carry out adaptation and transformation on the external interface for data reading and writing, application deployment, intelligent contract calling and on-chain event monitoring of XuperChain, and the details are not repeated here.
And fourthly, auditing and deploying the block chain bottom layer platform nanotubes. And testing the connectivity of the interface adaptation transformation of the bottom layer platform of the quasi-nanotube blockchain, and performing online deployment after testing to form one of the bottom layer platforms of the blockchain nanotube platform.
For this embodiment, connectivity for two blockchain underlying platform interface adaptations FISCO BCOS and XuperChain needs to be tested sequentially according to the interface standard specified in table 2. In the aspect of data read-write interface test, the functions of the acquisition block and transaction information are mainly tested, including normal acquisition, error processing and overtime conditions. In the aspect of application deployment interface testing, the creation, joining and exiting processes of an application chain are mainly tested, wherein the processes comprise flexibility and safety of parameter configuration. In the aspect of intelligent contract calling interface test, the deployment, initialization, upgrading and deleting of intelligent contracts are mainly tested, and all operations are ensured to be executed according to expectations. In the aspect of on-chain event monitoring interface test, the functions of registering, inquiring and deleting the event are mainly tested, and the accuracy and timeliness of event notification are ensured. If the above test is successfully passed, i.e. all interface functions can work normally according to the description of the interface specification, the input parameters are processed correctly, and the output parameters are consistent with the interface specification, FISCO BCOS and XuperChain can be deployed on line to the blockchain nanotube platform.
And fifthly, adapting the nano tube to the multi-block chain bottom layer platform. In this example, an adaptive nanotube for both FISCO BCOS and XuperChain blockchain bottom platforms was developed. And (3) repeating the third step and the fourth step for other blockchain bottom platforms needing nanotubes to realize the adaptive nanotubes of the multi-blockchain bottom platform. The blockchain bottom platform after the adaptation is managed and monitored by the blockchain nanotube platform in a unified way, and the blockchain application in the fields of government affairs, finance, traceability, medical treatment, certificate storage and the like is energized through the blockchain nanotube platform, and the connection relation is shown in figure 2.
In general, the invention provides a multi-block-chain bottom layer platform nano-tube method, which prepares unified interface specifications from four aspects of data reading and writing, application deployment, intelligent contract calling and on-chain event monitoring by analyzing the common functions of external interfaces of SDKs of different block-chain bottom layer platforms and combining with actual nano-tube requirements. The data interface formed by the method requires that each blockchain bottom layer platform can be adapted and modified on the premise of not changing the technical architecture of the blockchain bottom layer platform, and unified nano-tubes and interconnection among different blockchain bottom layer platforms are further realized. The method not only meets the requirement of flexible selection of the blockchain bottom layer platform in each region and each field, but also avoids the problems of 'technical kidnapping' and monopoly service possibly brought by a single technical service provider, and simultaneously solves the problems of poor cross-platform interoperability and high technical maintenance cost in a 'multi-chain coexistence' mode. The technical means of the invention ensures that the application developed based on the original blockchain bottom layer platform can be smoothly migrated, obviously reduces the complexity and cost of development and maintenance, and improves the flexibility and interoperability of the blockchain ecological system.
The above embodiments are only for illustrating the technical idea of the present invention, and the protection scope of the present invention is not limited thereto, and any modification made on the basis of the technical scheme according to the technical idea of the present invention falls within the protection scope of the present invention.