| Due to the characteristics of traceability,multi-party authentication,and difficulty to be tampered with,blockchain has gradually been applied to various scenarios such as data governance,government affairs,and anticounterfeiting traceability,empowering the real economy and promoting industrial transformation.Choosing the appropriate consensus algorithm for different scenarios plays a crucial role in the application of new blockchain scenarios.The consensus mechanism implementation of the existing blockchain system is to couple a single or a limited number of consensus algorithms into the system according to the requirements at the beginning of the design.This solution is not friendly to the scalability of the consensus algorithm,and it is difficult to satisfy the increasing number of application scenario requirements.At present,the research on the realization of pluggable consensus engines or modules in the blockchain is in the preliminary stage.The existing results have insufficient scalability for algorithms,and can only satisfy the replacement of similar consensus algorithms,and there is no design ideas for consulting.The research of this thesis is based on this background,and conform to my country’s support and encouragement for the development of consortium blockchain,the research and implementation of consensus engine are carried out to satisfy the loading and use of different types of consensus algorithms by consortium blockchains and BaaS platforms.The idea of microservices is integrated into the blockchain,providing new research ideas for the development of microservices and pluggable consensus in the blockchain.Through the research and analysis of different types of existing consensus algorithms and consensus engines,this thesis designs and implements a consensus engine under the microservice framework.The main research work includes:(1)Research and design of consensus engine.Through the investigation of different types of consensus algorithms,a unified consensus algorithm process model is constructed to explain different types of algorithms.Based on the process model,a consensus engine framework is designed.The consensus driver is divided into different functional modules according to the different process stages and functions,and the functional module interfaces are separated from the specific consensus implementation process.The networking mode and communication function of network nodes are researched and designed.According to the module interface,the PoW algorithm is loaded into the consensus engine for experiments.The results show that the designed consensus engine can satisfy the proposed requirements.(2)Introduce the microservice framework into the consensus engine.We consider the combination of microservices and consensus engines,split them into different microservices according to the modules designed by the engine,conduct research and design of key technologies under the microservices framework,and finally form a consensus engine model under the microservices framework.After that,each key technology is implemented concretely.(3)The Raft algorithm commonly used in the consortium blockchain is implemented modularly according to the interfaces in each microservice of the consensus engine,we focusing on the design of the protocol process and message types.Finally,an experimental scheme is designed to test the engine function.The experimental results show that the consensus engine under the microservice framework can satisfy the loading of different consensus algorithms,and when it is used,the extra overhead of network communication between microservices is within an acceptable range. |