Device and method for implementing blockchain experiment by controlling single chip microcomputer with custom instruction set
Through the custom instruction set control of the microcontroller, combined with the distributed management terminal and the blockchain experimental management platform, the difficulties of the existing blockchain experimental environment deployment and management are solved, and the rapid deployment and management of the blockchain experimental environment is realized, ensuring the safety, reliability and efficiency of the experimental environment.
Patent Information
- Application Number
- CN202411585603.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-08
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-11-08
AI Technical Summary
The existing blockchain experimental environment is not suitable for deployment in university laboratories, which may lead to a degradation of system performance and affect the experimental teaching of other courses. It lacks an efficient update management mechanism and cannot quickly upgrade and update blockchains.
The microcontroller is controlled by a custom instruction set, and the distributed management terminal is equipped with the blockchain experimental management platform server, which realizes Socket monitoring, registration, installation package push, mass command, status monitoring and other functions, supports multi-threaded push and message queue notification, ensuring the rapid deployment and management of the blockchain environment.
It realizes the rapid deployment and management of blockchain experimental environment, ensures the safety and reliability of the experimental environment, reduces costs, improves experimental efficiency, and supports the switching of multiple blockchain technologies.
Smart Images

Figure CN119149348B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of single-chip microcomputer blockchain deployment control, and relates to a device and method for controlling a single-chip microcomputer to implement a blockchain experiment using a custom instruction set. Background Art
[0002] As an emerging information technology, the core advantages of blockchain technology lie in decentralization, data immutability, and efficient consensus mechanism. This technical system not only integrates knowledge from multiple high-tech fields such as distributed systems, advanced encryption algorithms, P2P network communications, and sophisticated consensus algorithms, but also requires full consideration of the security, stability, and scalability of the system during the design and implementation process. Therefore, building a blockchain environment that is both stable, reliable, and efficient places extremely high demands on the professional quality and technical capabilities of technical personnel, which is undoubtedly a daunting challenge for those who lack relevant technical backgrounds.
[0003] Chinese patent CN111324599A discloses a blockchain experimental system and management method, and CN114708773A discloses a blockchain teaching system. The above patents all use conventional servers and experimental PCs for experiments. The existing experimental PCs in university laboratories usually have a variety of experimental environments installed to support the teaching needs of different courses. If a blockchain environment is added to these PCs, not only may the system performance decline due to resource competition, but it is also very easy to damage the existing experimental environment, affecting the experimental teaching of other courses, and will also bring additional burdens to the management and maintenance of the laboratory.
[0004] The existing experimental environment is not suitable for blockchain experiments. It lacks an efficient update management mechanism and cannot quickly upgrade and update the blockchain. Teachers need to switch between various blockchain technologies during the teaching process, and the existing laboratory management system is difficult to support multiple blockchain systems with different technologies at the same time. Summary of the invention
[0005] In view of this, the purpose of the present invention is to provide a device and method for controlling a single-chip microcomputer with a custom instruction set to implement a blockchain experiment.
[0006] In order to achieve the above object, the present invention provides the following technical solutions:
[0007] On the one hand, the present invention provides a device for implementing a blockchain experiment by controlling a single-chip microcomputer with a custom instruction set, comprising:
[0008] Distributed management terminal: equipped with a blockchain experiment management platform server, using a custom instruction set to implement: Socket monitoring, receiving instructions from the MCU; registering the MCU; extracting the ARM-compiled blockchain installation file from the installation directory and compressing it to generate an installation package; pushing the installation package to multiple MCUs through multiple thread groups at the same time; sending group instructions to registered MCUs; updating the blockchain environment of each MCU; sending instructions to control the blockchain operation on the MCU; monitoring the status of each MCU and blockchain; browsing blockchain information;
[0009] MCU: Equipped with the blockchain experiment management platform client, as a node of the blockchain, it is used to establish a Socket connection with the distributed management terminal; apply for registration with the server; receive the installation package pushed by the server; subscribe to the installation package update message of the server; pull the update package and install it; report the update status; receive and execute the group instructions of the server; report the operation status of the blockchain node.
[0010] Furthermore, the distributed management terminal is composed of a host computer, an intranet mirror server, and multiple push servers;
[0011] The blockchain experiment management platform server includes a registration center module, a scanning service module, a file push module, an installation package management module, a permission management module, a monitoring service module, a monitoring management service module, a message push module, a message queue module, and a block browsing module;
[0012] The registration center module is used to register the newly started MCU client;
[0013] The scanning service module is used to scan the installation directory, find the blockchain installation files therein, and compress them to generate a blockchain installation package;
[0014] The file push module pushes the blockchain installation package to all registered MCUs in parallel through multiple thread groups running in one or more push servers;
[0015] The installation package management module runs in the intranet mirror server and is used to manage the installation package;
[0016] The authority management module is used to manage system user authority;
[0017] The monitoring service module is used to monitor the status of registered MCUs;
[0018] The monitoring management service module is used to start Socket monitoring and receive instructions from registered microcontrollers;
[0019] The message push module is used to push messages in the message queue to the registered MCU;
[0020] The message queue module is used to store blockchain update packages and wait for the MCU to actively pull them;
[0021] The block browsing module is used to browse blockchain information.
[0022] Furthermore, the intranet mirror server is built based on the distributed object storage MinIO. MinIO uses erasure coding mechanism to ensure high reliability and bit decay protection to ensure data integrity. File objects are uploaded to MinIO, with the Bucket name as the directory and the file name as the next-level directory.
[0023] Furthermore, the custom instruction set includes at least a registration instruction LAB_REG, a switch instruction LAB_SET, a reset instruction LAB_RESET, a check code receiving instruction LAB_CHKM, a subscription update instruction LAB_SUB, a Hyperledger Fabric channel creation instruction HF_Peer_CH_Create, a Hyperledger Fabric create and join channel instruction HF_Peer_CH_Create_Join, a Hyperledger Fabric node information reporting instruction HF_Peer_GetInfo, a Peer node join channel view instruction HF_Peer_CH_List_All, a Peer node chain code acquisition instruction HF_Peer_CC_List, an Ethereum initialization genesis block instruction ETH__Init, and an Ethereum new account creation instruction ETH_Account_New.
[0024] Furthermore, the instructions in the custom instruction set are used as the communication protocol between the server and the client. The instruction set is first parsed before sending, and the instruction set is parsed into the same number of instructions as the receiving end, and then the instructions are sent to all receiving ends; after receiving the instructions, the receiving end first parses and converts the instructions, and then executes the instructions.
[0025] On the other hand, the present invention provides a method for implementing a blockchain experiment by controlling a single-chip microcomputer with a custom instruction set, comprising the following steps:
[0026] The host computer compiles and adjusts the blockchain experiment source code of the arm architecture to obtain the blockchain installation file suitable for the single-chip microcomputer and stores it in the directory to be installed;
[0027] The host computer scans the directory to be installed, compresses the blockchain installation file, and generates different installation packages and corresponding installation file verification codes for different blockchain types;
[0028] The host computer pushes the installation package to the intranet mirror server for storage;
[0029] The host computer pushes the installation package to each online MCU;
[0030] The host computer pushes the installation file verification code corresponding to each installation package to the corresponding microcontroller;
[0031] The single chip microcomputer uses the installation package file verification code to verify the integrity of the received installation package;
[0032] Teachers and students use single-chip microcomputers to conduct blockchain teaching experiments.
[0033] Furthermore, when pushing the installation package, the host computer starts multiple thread groups for pushing. Each thread group occupies a push server exclusively. Each thread group starts 50 push threads by default. Each microcontroller is pushed by 5 push threads by default. The host computer automatically determines the resource status of the push server and automatically adjusts the number of threads according to the push server resources.
[0034] Furthermore, after the microcontroller is started, a Socket connection is established with the host computer to register with the host computer; the Socket disables the Nagle algorithm and uses the zero-copy technology.
[0035] Furthermore, the host computer divides the installation file into multiple segments according to the number of threads, and each thread transmits one segment of the installation file; after the microcontroller successfully receives it, it merges all the segments into one file, and then generates a file verification code, which is compared with the received installation file verification code to verify the integrity of the received file.
[0036] Furthermore, when the blockchain needs to be updated, the host computer pushes the update package to the intranet mirror server, and sends the blockchain update message to each microcontroller through the message queue. After each microcontroller receives the message, it verifies whether the local computer is pulling or has received the update package. If not, it pulls the latest version of the update package from the intranet mirror server for installation.
[0037] The beneficial effects of the present invention are as follows: the present invention utilizes a pure intranet to build a blockchain network, thereby ensuring the safety and reliability of the experimental environment; in order to facilitate the management of the experimental environment, the experimental environment is quickly deployed and reset through a blockchain experiment management platform, and the experimental environment is simple to build; the blockchain experiment management platform implements multi-threaded file push, and simultaneously pushes installation packages to different single-chip microcomputers, and supports breakpoint resumption to ensure that file reception is complete; each single-chip microcomputer is notified through a message queue to ensure that message transmission is not lost; a single-chip microcomputer is used as a blockchain node instead of a server, which is low in cost; the single-chip microcomputer is based on an arm architecture, has low energy consumption, is easy to deploy, and can quickly form a chain.
[0038] Other advantages, objectives and features of the present invention will be described in the following description to some extent, and to some extent, will be obvious to those skilled in the art based on the following examination and study, or can be taught from the practice of the present invention. The objectives and other advantages of the present invention can be realized and obtained through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention will be described in detail below in conjunction with the accompanying drawings, wherein:
[0040] Figure 1 This is a schematic diagram of the experimental terminal connection;
[0041] Figure 2 This is a schematic diagram of the functional modules of the blockchain experiment management platform (LabMS) server;
[0042] Figure 3 A flow chart of the method for implementing blockchain experiments by using a custom instruction set to control a single-chip microcomputer;
[0043] Figure 4 This is a schematic diagram of the multi-threaded push process of the installation package;
[0044] Figure 5 This is a schematic diagram of parallel push in multiple computer rooms;
[0045] Figure 6 This is a schematic diagram of the instruction control flow. DETAILED DESCRIPTION
[0046] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the illustrations provided in the following embodiments only illustrate the basic concept of the present invention in a schematic manner, and the following embodiments and features in the embodiments can be combined with each other without conflict.
[0047] Among them, the drawings are only used for illustrative explanations, and they only represent schematic diagrams rather than actual pictures, and should not be understood as limitations on the present invention. In order to better illustrate the embodiments of the present invention, some parts of the drawings may be omitted, enlarged or reduced, and do not represent the size of actual products. For those skilled in the art, it is understandable that some well-known structures and their descriptions in the drawings may be omitted.
[0048] The same or similar numbers in the drawings of the embodiments of the present invention correspond to the same or similar parts; in the description of the present invention, it should be understood that if the terms "upper", "lower", "left", "right", "front", "rear", etc. indicate the orientation or position relationship, they are based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation. Therefore, the terms describing the position relationship in the drawings are only used for illustrative purposes and cannot be understood as limiting the present invention. For ordinary technicians in this field, the specific meanings of the above terms can be understood according to specific circumstances.
[0049] The present invention provides a method for implementing a blockchain experiment by controlling a single-chip microcomputer with a custom instruction set, and realizes a set of instruction sets by cooperating with a terminal to control each single-chip microcomputer to quickly form a blockchain experiment environment, thereby realizing unified management of blockchain experiments. Blockchains are divided into public chains, alliance chains, and private chains. In this embodiment, the experimental process of the alliance chain is mainly described, and two alliance chains, Hyperledger Fabric and Ethereum, are supported. Each teaching experiment can select one of them for experiment according to teaching needs.
[0050] For security reasons, the education network has limited access to the Internet. In order to ensure the safety and stability of teaching experiments, the establishment of a blockchain laboratory requires all resources to run on the intranet.
[0051] In this method, first download the source code related to the arm architecture of Hyperledger Fabric and Ethereum. The default compilation and running environment of Hyperledger Fabric and Ethereum are both x86 platforms. In order to run on a single-chip microcomputer, the arm architecture needs to be used. Compared with the x86 platform, the arm architecture has lower power consumption. When compiling, specify the ARCH parameter as arm64. At the same time, you also need to adjust some compilation parameters. The compilation is more complicated than the x86 version.
[0052] Store the compiled Hyperledger Fabric and Ethereum in the specified directory (LabPKG). The scheduled scanning service Lab_PKGScan of the blockchain test management platform (LabMS) will automatically scan the directory. Lab_PKGScan will call the Lab_7zip({installation package file name}) function to efficiently compress the scanned blockchain installation file, so that the size is minimized, and the network resource consumption is small when transmitted to the microcontroller through the network, and the speed is faster. Different installation packages are generated for different blockchains, and the Lab_MD5ValidateFile({installation package file name}, {salt}) function is called to generate a corresponding installation package file verification code for verifying the integrity of the installation package file. The verification code is stored in the blockchain test management platform (LabMS).
[0053] These blockchain installation packages are pushed to the intranet mirror server for storage. The mirror server that stores these installation packages is built based on the high-performance distributed object storage MinIO. MinIO uses the Erasure Code mechanism to ensure high reliability and Bit Rot protection to ensure data integrity. File objects are uploaded to MinIO, with the Bucket name as the directory and the file name as the next-level directory.
[0054] Then LabMS actively pushes the blockchain installation package to each online MCU. When LabMS pushes, it starts multiple thread groups as needed. The push service is distributed. Multiple thread groups can run on one push server, or each thread group can occupy one push server. Each thread group starts 50 push threads by default. The default number of push threads for each MCU is 5, so it can be pushed to 10 MCUs at the same time. LabMS automatically determines the server resource status and automatically adjusts the number of threads according to the server resources to prevent the CPU from running at a high level for a long time and ensure the stability of the server. Since there are many servers in the computer room, if there are 50 nodes doing experiments at the same time, two thread groups can be started and run on 2 push servers for concurrent push to ensure the efficiency of push.
[0055] A laboratory usually has multiple computer rooms. This method supports different blockchain experiments in different computer rooms at the same time. For example, computer room A uses Hyperledger Fabric for experiments, and computer room B uses Ethereum for experiments. One part of the thread group of LabMS pushes Hyperledger Fabric to the microcontroller in computer room A, and the other part of the thread group pushes Ethereum to the microcontroller in computer room B.
[0056] LabMS's push service supports breakpoint-resume push. LabMS sends the verification code of the installation package to each microcontroller to verify whether the file is received completely.
[0057] LabMS also sends new installation package messages to each MCU through LabMQ (message queue). After receiving the message, each MCU verifies whether the local machine is pulling the installation package or has successfully received the installation package. If it is not in these two states, it pulls the installation package of the corresponding version from the mirror server and then decompresses and installs it.
[0058] The experiment teacher selects Hyperledger Fabric or Ethereum on the blockchain experiment management platform (LabMS) as needed. LabMS sends a setting command (LAB_SET {machine room number}_{number} HF / ETH) to remotely control the microcontroller to switch to the corresponding alliance chain.
[0059] Before each experiment, the blockchain test management platform (LabMS) sends a reset command (LAB_RESET {room number}_{number}) to remotely control the microcontroller to pull the blockchain installation package from the mirror server, delete the local cache data, reset the experimental environment, and ensure the cleanliness of the experimental environment.
[0060] Students develop smart contracts and upload them to the chain for testing. The experiment teacher can also explain the working mechanism and source code of Hyperledger Fabric and Ethereum, and students can also become familiar with blockchain-related operation commands. At the same time, in order to facilitate students to master blockchain applications, they can also conduct experiments in combination with scenario applications, such as credit certificates, product traceability and other blockchain applications.
[0061] like Figure 1 As shown, each student's experimental terminal can select a PC or a single-chip microcomputer for experiment through a switch, and the single-chip microcomputer is connected to the monitor via HDMI to VGA.
[0062] like Figure 2 As shown in the figure, the blockchain experiment management platform (LabMS) server has the following functions:
[0063] 1) Start Socket monitoring and receive instructions from the microcontroller;
[0064] 2) Registration center function: after each microcontroller is started, it will be registered to the blockchain test management platform (LabMS) through the LabMS client;
[0065] 3) File push service: Multi-threaded push of installation packages to MCU nodes, supporting breakpoint continuation;
[0066] 4) Command control: Send commands to the successfully registered MCUs, such as sending a reset command (LAB_RESET {machine room number}_{number}) to control the MCU to reset the blockchain (Hyperledger Fabric, Ethereum) environment;
[0067] 5) Message service: Update package messages are stored in the message queue LabMQ;
[0068] 6) A single-chip computer that records the successful update of the blockchain environment, used to confirm that all target machines have been successfully updated;
[0069] 7) Monitor the status of each MCU (blockchain node);
[0070] 8) Browse blockchain information.
[0071] Each MCU is a node. The MCU runs the client of the blockchain test management platform (LabMS). The client communicates with the server through Socket. The control command communication uses the TCP protocol, and the file transfer uses the UDP protocol. The client has the following functions:
[0072] 1) Automatically establish a Socket connection with the LabMS server after startup;
[0073] 2) Send a registration command (LAB_REG {room number}_{number}) to register with the registration center of LabMS, indicating that this node is normal;
[0074] 3) Receive the installation package pushed by the server;
[0075] 4) Subscribe to LabMQ messages and automatically consume new messages;
[0076] 5) Pull the blockchain installation package to the MCU and support breakpoint resuming;
[0077] 6) Automatically decompress and install;
[0078] 7) Report the success or failure of the update installation package, and automatically retry if it fails;
[0079] 8) Receive LabMS instructions to switch to Hyperledger Fabric or Ethereum;
[0080] 9) Report the operation status of blockchain nodes.
[0081] like Figure 3 As shown in the figure, the method of using a custom instruction set to control a single-chip microcomputer to implement a blockchain experiment specifically includes the following steps:
[0082] ①After Hyperledger Fabric or Ethereum is compiled through arm, the scanning service Lab_PKGScan will automatically scan the directory.
[0083] ②Call the Lab_7zip({installation package file name}) function to compress, and call the Lab_MD5ValidateFile({installation package file name}, {salt}) function to generate a corresponding installation package file verification code
[0084] ③Upload the installation package and file verification code to the mirror server;
[0085] ④LabMS starts the monitoring service. After the MCU (LabMS client) starts, it establishes Socket communication with LabMS. The Socket disables the Nagle algorithm to reduce the delay of small data packets. It uses zero-copy technology to avoid copying data between user space and kernel space, improving performance. Subsequent control instructions are sent through this channel, which is the main channel between the MCU and LabMS.
[0086] ⑤After each MCU is started, it sends the registration command (LAB_REG {machine room number}_{number}) to the registration center through the main channel;
[0087] ⑥LabMS starts multiple push threads, establishes multiple separate transmission Socket channels with the client, divides the file into multiple segments according to the size of the installation package, and the size of each segment = ROUNDUP (file size / number of threads). Each thread transmits a segment of the file using the UDP protocol. After the MCU client successfully receives the files, these segments are merged into one file. The merged file calls the Lab_MD5ValidateFile ({installation package file name}, {salt}) function to generate a file verification code, which is compared with the received verification code to verify whether the received file is complete. The file verification code is sent through the main channel. TCP is more reliable than UDP, ensuring that the file verification code is sent to the MCU successfully.
[0088] ⑦The installation package management service sends the package message that needs to be updated to LabMQ;
[0089] ⑧The MCU sends a subscription command (LAB_SUB {room number}_{number}) to subscribe to the blockchain installation package information that needs to be updated from LabMQ;
[0090] ⑨ The MCU sends and receives the verification code instruction (LAB_CHKM{machine room number}_{number}) through the main channel, starts multiple download threads (the default number of threads is 5) to pull the installation package from the mirror server, and divides the file into multiple segments according to the size of the installation package. Each download thread downloads a segment of the installation package. After the download is successful, these segments are merged into one file. The merged file calls the Lab_MD5ValidateFile({installation package file name}, {salt}) function to generate a file verification code and compare it with the received verification code to verify whether the file is downloaded completely.
[0091] The file transfer process of steps ⑥ and ⑨ is as follows Figure 4 shown.
[0092] like Figure 5 As shown, a laboratory generally has multiple computer rooms, and the push service of the blockchain experiment management platform (LabMS) pushes the installation package to the microcontrollers in each computer room in parallel.
[0093] For the custom instruction set of the present invention, such as Figure 6 As shown in the figure, the command is the communication protocol between the server and the client. It can be sent from the server to the client or from the client to the server. For example, reporting blockchain node information: HF_UP {machine room number}_{number} {node information} is sent from the client to the server. The command can be sent to one or more receiving terminals and needs to be parsed before sending.
[0094] In this embodiment, taking the collection instruction HF_Peer_CH_List_All as an example, it is used to view the channels joined by all peer nodes of the blockchain on the single-chip microcomputer. Before sending, the sending end will parse the instructions into the same number according to the number of clients, and the sending end will send these instructions to all clients. After receiving the instructions, the client returns the blockchain information on the single-chip microcomputer to LabMS;
[0095] After receiving the instruction, the client also needs to parse and convert the instruction and then execute it:
[0096] Hyperledger Fabric creates a channel with the following command:
[0097] HF_Peer_CH_Create {Room Number}_{Number} {ChannelName}
[0098] The client will parse the command converted into blockchain:
[0099] peer channel create -c {ChannelName}
[0100] Hyperledger Fabric creates and joins a channel. The instructions are:
[0101] HF_Peer_CH_Create_Join {Room Number}_{Number} {ChannelName}
[0102] The client will parse and convert into two commands to execute the blockchain:
[0103] peer channel create {ChannelName}
[0104] peer channel join -b {ChannelName}
[0105] Finally, the client executes the above two commands, and Hyperledger Fabric creates and joins the specified channel.
[0106] In the present invention, the custom instructions at least include registration instruction LAB_REG, switching instruction LAB_SET, reset instruction LAB_RESET, receiving verification code instruction LAB_CHKM, subscription update instruction LAB_SUB, Hyperledger Fabric channel creation instruction HF_Peer_CH_Create, Hyperledger Fabric create and join channel instruction HF_Peer_CH_Create_Join, Hyperledger Fabric node information reporting instruction HF_Peer_GetInfo, Peer node join channel view instruction HF_Peer_CH_List_All, Peer node chain code acquisition instruction HF_Peer_CC_List, Ethereum initialization genesis block instruction ETH__Init, Ethereum new account creation instruction ETH_Account_New. The specific description of each instruction is as follows:
[0107] (1) Command: LAB_REG {machine room number}_{number}
[0108] Description: The MCU (client) sends the information to LabMS, and the client registers in the registration center of LabMS, so that LabMS knows the status of the MCU.
[0109] (2) Command: LAB_SET {room number}_{number} HF / ETH
[0110] Description: LabMS sends to the MCU (client), remotely controls the MCU to switch to the corresponding alliance chain
[0111] (3) Command: LAB_RESET {room number}_{number}
[0112] Description: LabMS is sent to the MCU (client), remotely controlling the client to re-pull the blockchain installation package from the mirror server, delete the local cache data, and reset the experimental environment.
[0113] (4) Command: LAB_SUB {machine room number}_{number}
[0114] Description: The MCU (client) sends to LabMS and subscribes to the blockchain installation package information that needs to be updated from the message queue LabMQ
[0115] (5) Command: LAB_CHKM{machine room number}_{number}
[0116] Description: The MCU (client) sends to LabMS, and the client sends and receives the verification code command through the main channel to obtain the verification code.
[0117] (6) Instructions for controlling the blockchain Hyperledger Fabric:
[0118] ①Command: HF_Peer_CH_Create{room number}_{number}
[0119] Description: LabMS is sent to the MCU (client), and the client controls Hyperledger Fabric to create a channel.
[0120] Execute: peer channel create -c {ChannelName}
[0121] ②Command: HF_Peer_CH_Create_Join{machine room number}_{number}
[0122] Description: LabMS sends combined instructions to the MCU (client), and the client controls Hyperledger Fabric to create and join channels.
[0123] Execute: peer channel create {ChannelName}
[0124] peer channel join -b {ChannelName}
[0125] ③Command: HF_Peer_GetInfo{room number}_{number}
[0126] Description: LabMS sends to the MCU (client), and the client returns the Hyperledger Fabric node information. Execution: peer channel getinfo -c {ChannelName}
[0127] ④Command: HF_Peer_CH_List_All
[0128] Description: LabMS is sent to all MCUs (clients) to view the channels joined by the Hyperledger Fabric peer nodes on all MCUs. The client executes the Hyperledger Fabric command to return the information to LabMS.
[0129] Execution: peer channel list
[0130] ⑤ Command: HF_Peer_CC_List {room number}_{number}
[0131] Description: LabMS is sent to all MCUs (clients) to obtain the chain code of the Peer node of Hyperledger Fabric on the MCU.
[0132] Execution: peer chaincode list
[0133] (7) Instructions for controlling the Ethereum blockchain:
[0134] ①Command: ETH__Init{machine room number}_{number}
[0135] Description: LabMS is sent to the MCU (client), and the client controls Ethereum to initialize a new genesis block.
[0136] Execute: geth init.
[0137] ②Command: ETH_Account_New{room number}_{number}
[0138] Description: LabMS sends to the MCU (client), and the client controls Ethereum to create a new account.
[0139] Execute: geth account new.
[0140] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution, which should be included in the scope of the claims of the present invention.
Claims
1. A device for implementing blockchain experiments by controlling a single-chip microcomputer using a custom instruction set, characterized in that: include: Distributed management terminal: equipped with a blockchain experiment management platform server, using a custom instruction set to implement: Socket monitoring and receiving instructions from the microcontroller; Register the MCU; extract the ARM-compiled blockchain installation file from the installation directory and compress it to generate an installation package; push the installation package to multiple MCUs through multiple thread groups at the same time; push different blockchain installation packages to different MCUs at the same time; send group instructions to registered MCUs; update the blockchain environment of each MCU; reset the blockchain environment of each MCU; switch blockchains through two-way communication with the MCU; send instructions to control blockchain operations on the MCU; monitor the status of each MCU and blockchain; Browse blockchain information; MCU: Equipped with the blockchain experiment management platform client, as a blockchain node, used to establish a Socket connection with the distributed management terminal; apply for registration with the server; receive the installation package pushed by the server; subscribe to the installation package update message of the server; pull the update package and install it; report the update status; receive and execute the group instructions of the server; report the operation status of the blockchain node; The distributed management terminal is composed of a host computer, an intranet mirror server and multiple push servers; The blockchain experiment management platform server includes a registration center module, a scanning service module, a file push module, an installation package management module, a permission management module, a monitoring service module, a monitoring management service module, a message push module, a message queue module and a block browsing module; The registration center module is used to register the newly started single-chip computer client; The scanning service module is used to scan the directory to be installed, find the blockchain installation file therein, and compress it to generate a blockchain installation package; The file push module pushes the blockchain installation package to all registered MCUs in parallel through multiple thread groups running in one or more push servers, and supports breakpoint continuation. The installation package management module runs in the intranet mirror server and is used to manage the installation package; The authority management module is used to manage system user authority; The monitoring service module is used to monitor the status of the registered single chip microcomputer; The monitoring management service module is used to start Socket monitoring and receive instructions from the registered single-chip microcomputer; The message push module is used to push the messages in the message queue to the registered single chip microcomputer; The message queue module is used to store blockchain update packages and wait for the microcontroller to actively pull them; The block browsing module is used to browse blockchain information; The custom instruction set includes a registration instruction LAB_REG, a switch instruction LAB_SET, a reset instruction LAB_RESET, a verification code receiving instruction LAB_CHKM, a subscription update instruction LAB_SUB, a Hyperledger Fabric channel creation instruction HF_Peer_CH_Create, a Hyperledger Fabric channel creation and joining instruction HF_Peer_CH_Create_Join, a Hyperledger Fabric node information reporting instruction HF_Peer_GetInfo, a Peer node channel joining view instruction HF_Peer_CH_List_All, a Peer node chain code acquisition instruction HF_Peer_CC_List, an Ethereum initialization genesis block instruction ETH__Init, and an Ethereum new account creation instruction ETH_Account_New; The registration instruction LAB_REG is used to be sent by the single-chip microcomputer to the registration center module of the blockchain experiment management platform server to register the blockchain experiment management platform client carried by the single-chip microcomputer; The switching instruction LAB_SET is used to be sent to the single-chip microcomputer by the blockchain experiment management platform server, so as to control the single-chip microcomputer to switch to a different alliance chain; The reset instruction LAB_RESET is used to be sent to the single-chip microcomputer by the blockchain experiment management platform server, remotely controlling the single-chip microcomputer to re-pull the blockchain installation package from the mirror server, delete the local cache data, and reset the experimental environment; The receiving verification code instruction LAB_CHKM is used to be sent by the single chip microcomputer to the blockchain experiment management platform server to obtain the installation file verification code to perform integrity verification on the installation file; The subscription update instruction LAB_SUB is used to be sent by the single-chip microcomputer to the message queue module of the blockchain experiment management platform server to subscribe to the blockchain installation package information that needs to be updated.
2. The device for implementing blockchain experiment by controlling a single-chip microcomputer using a custom instruction set according to claim 1 is characterized in that: The intranet mirror server is built based on the distributed object storage MinIO. MinIO uses erasure coding mechanism to ensure high reliability and bit decay protection to ensure data integrity. File objects are uploaded to MinIO, with the Bucket name as the directory and the file name as the next-level directory.
3. The device for implementing blockchain experiment by controlling a single-chip microcomputer using a custom instruction set according to claim 1 is characterized in that: The instructions in the custom instruction set serve as the communication protocol between the server and the client. Before sending, the instruction set is first parsed into the same number of instructions as the receiving end, and then the instructions are sent to all receiving ends; after receiving the instructions, the receiving end first parses and converts the instructions, and then executes the instructions.
4. A method for implementing a blockchain experiment by controlling a single-chip microcomputer using a custom instruction set, characterized in that: The device for implementing a blockchain experiment based on a single-chip microcomputer controlled by a custom instruction set according to claim 1 comprises the following steps: The host computer compiles and adjusts the blockchain experiment source code of the arm architecture to obtain the blockchain installation file suitable for the single-chip microcomputer and stores it in the directory to be installed; The host computer uses the scheduled scanning service Lab_PKGScan to regularly scan the directory to be installed. Lab_PKGScan calls the Lab_7zip({installation package file name}) function to compress the scanned blockchain installation file, and calls the Lab_MD5ValidateFile({installation package file name}, {salt}) function to generate different installation packages and corresponding installation file verification codes for different blockchain types; The host computer pushes the installation package to the intranet mirror server for storage; The MCU sends the registration instruction LAB_REG to the host computer for registration, and the host computer pushes the installation package to each online MCU; The MCU sends the receive verification code instruction LAB_CHKM to the host computer to obtain the installation file verification code. The host computer pushes the installation file verification code corresponding to each installation package to the corresponding MCU; The single chip microcomputer uses the installation package file verification code to verify the integrity of the received installation package; Teachers and students use single-chip microcomputers to conduct blockchain teaching experiments; When pushing the installation package, the host computer starts multiple thread groups for pushing. Each thread group occupies a push server. Each thread group starts 50 push threads by default. Each MCU is pushed by 5 push threads by default. The host computer automatically determines the push server resource status and automatically adjusts the number of threads according to the push server resources. The host computer supports pushing different blockchain installation packages to different MCUs at the same time; the host computer supports sending the switching instruction LAB_SET to communicate with the MCU in two directions to switch the blockchain; the host computer supports sending the reset instruction LAB_RESET to communicate with the MCU in two directions to pull the blockchain installation package from the mirror server, delete the local cache data, and reset the experimental environment; Students can use the switch to select PC or MCU to conduct different experiments; The host computer and the microcontroller also carry out two-way communication or control through the following custom instructions: (1) The instructions for controlling the Hyperledger Fabric blockchain include: HF_Peer_CH_Create instruction: sent by the host computer to the MCU to control Hyperledger Fabric to create a channel; HF_Peer_CH_Create_Join instruction: sent by the host computer to the MCU to control Hyperledger Fabric to create and join the channel; HF_Peer_GetInfo command: the host computer sends it to the MCU, and the MCU returns the Hyperledger Fabric node information; HF_Peer_CH_List_All instruction: sent by the host computer to all MCUs to view the channels joined by the peer nodes of Hyperledger Fabric on all MCUs. The MCU executes the Hyperledger Fabric command and returns the information to LabMS; HF_Peer_CC_List instruction: sent by the host computer to all MCUs to obtain the chain code of the Peer node of Hyperledger Fabric on the MCU; (2) Instructions for controlling the Ethereum blockchain include: ETH__Init instruction: sent by the host computer to the MCU to control Ethereum to initialize a new genesis block; ETH_Account_New instruction: sent by the host computer to the MCU to control Ethereum to create a new account.
5. The method for implementing a blockchain experiment by controlling a single-chip microcomputer using a custom instruction set according to claim 4 is characterized in that: After the microcontroller is started, it establishes a Socket connection with the host computer and registers with the host computer; the Socket disables the Nagle algorithm and uses zero-copy technology.
6. The method for implementing a blockchain experiment by controlling a single-chip microcomputer using a custom instruction set according to claim 5 is characterized in that: The host computer divides the installation file into multiple segments according to the number of threads, and each thread transmits one segment of the installation file; after the microcontroller successfully receives it, it merges all the segments into one file, and then generates a file verification code, which is compared with the received installation file verification code to verify the integrity of the received file.
7. The method for implementing a blockchain experiment by controlling a single-chip microcomputer using a custom instruction set according to claim 6 is characterized in that: When the blockchain needs to be updated, the host computer pushes the update package to the intranet mirror server, and the MCU sends the subscription update instruction LAB_SUB to the host computer. The host computer sends the blockchain update message to each MCU through the message queue. After each MCU receives the message, it verifies whether the local machine is pulling or has received the update package. If not, it pulls the latest version of the update package from the intranet mirror server for installation.
Citation Information
Patent Citations
Block chain teaching system
CN114708773A
Block chain experiment system and management method
CN111324599A
Experimental scheme parallel deduction management and control system
CN113535389A
Block chain edge computing system
CN114124956A
Cross-platform desktop application batch installation and centralized configuration management system
CN117008933A