System status loading method, system, device and computer-readable storage medium

By inserting binary data and structured data interchange method between blockchain nodes, and batch reading and writing state data, the problem of low state operation efficiency in the existing technology is solved, and efficient state data management and throughput improvement is achieved.

CN120123430BActive Publication Date: 2025-08-12GUANGDONG-HONG KONG-MACAO GREATER BAY AREA DIGITAL ECONOMY RESEARCH INSTITUTE (INTERNATIONAL ADVANCED TECHNOLOGY APPLICATION PROMOTION CENTER (SHENZHEN) +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510616029.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-14
Publication Date
2025-08-12
Estimated Expiration
2045-05-14

AI Technical Summary

Technical Problem

State read and write operations of existing blockchain smart contracts lead to high latency and low throughput, excessive consumption of computing resources, affecting execution efficiency and scalability.

Method used

Through the interchange method between binary data and structured data, the state data of the first node is converted into the second state data and read in batches to the second node, and then converted into the third state data after responding to the update operation in the second node, and stored in the blockchain. The instruction insertion technology is used to insert into the data interaction protocol to realize batch reading and writing.

Benefits of technology

Improves the management capabilities of state data, reduces frequent access to blockchain storage, and improves execution efficiency and throughput.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120123430B_ABST
    Figure CN120123430B_ABST
Patent Text Reader

Abstract

The present application relates to the field of blockchain technology, and in particular to a method, system, device, and computer-readable storage medium for loading system status. The method comprises converting first state data in a first node into second state data by an interchange method between binary data and structured data, and then reading the data in batches into a second node; responding to an update operation for the second state data in the second node, and converting the updated second state data into third state data by the interchange method to store the data in the blockchain. The present application loads the first state data in batches into the second node by an interchange method, and then writes the updated second state data in batches into the first node and other nodes on the blockchain by an interchange method between binary data and structured data. The state data is obtained in batches before being updated, and stored in batches after being updated, without the need to read and write the state data one by one, thereby improving the management capability of the state data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain technology, and in particular to a method, system, device, and computer-readable storage medium for loading system status. Background Art

[0002] Blockchain smart contracts, as self-executing protocols, have been widely adopted in numerous fields. With the rapid development of blockchain technology, various smart contract platforms have proposed diverse smart contract execution models. Currently, the most widely adopted smart contract platforms convert state reads in contract code into SLOAD (load from storage) instructions and state writes into SSTORE (write to storage) instructions. These instructions are executed one by one by the smart contract's execution engine. Therefore, each state read and write in a smart contract triggers access to blockchain storage, resulting in higher latency and lower throughput. This is particularly true with frequent state data interactions and complex contract execution, leading to significant computational resource consumption and reduced execution efficiency.

[0003] Therefore existing technology still needs to be improved and improved. Summary of the Invention

[0004] The technical problem to be solved by the present application is to provide a system status loading method, system, device and computer-readable storage medium in response to the deficiencies of the existing technology.

[0005] In order to solve the above technical problems, the first aspect of the present application provides a method for loading a system state, wherein the method for loading a system state specifically includes:

[0006] Converting the first state data in the first node into the second state data by using a binary data and structured data interchange method, so as to batch read the data into the second node, wherein the binary data and structured data interchange method includes a deserialization method and a serialization method;

[0007] An update operation for the second state data is responded to within the second node, and the updated second state data is converted into third state data by using the binary data and structured data interchange method, so as to be stored in the blockchain.

[0008] The system status loading method, wherein the deserialization method is used to convert binary data into structured data, and the serialization method is used to convert structured data into binary data.

[0009] The system state loading method, wherein, before converting the first state data in the first node into the second state data by using the binary data and structured data interchange method for batch reading into the second node, the method further comprises:

[0010] Based on the instruction insertion technology, the interchange method between binary data and structured data is inserted into the data interaction protocol between blockchain nodes.

[0011] The system state loading method, wherein the method of inserting the interchange method between binary data and structured data based on instruction instrumentation technology into the data interaction protocol between blockchain nodes specifically includes:

[0012] In response to a compilation instruction for the data interaction protocol, compile the data interaction protocol by a compiler;

[0013] During the compilation process of the compiler, one of the serialization method and the deserialization method is inserted before the protocol business logic of the data interaction protocol through instruction insertion technology, and the other method is inserted after the protocol business logic of the data interaction protocol.

[0014] The system status loading method, wherein the data interaction protocol is one of a blockchain smart contract, a distributed database consistency protocol, and a distributed database data transmission protocol.

[0015] The method for loading the system status, wherein the data interaction protocol is a smart contract of the blockchain;

[0016] The first state data in the first node is converted into the second state data by using the interchange method between binary data and structured data, so as to be read into the second node in batches, specifically:

[0017] Calling a deserialization method to convert the first state data in the first node into the second state data, and reading the second state data in batches into the second node;

[0018] The responding to the update operation for the second state data in the second node and converting the updated second state data into third state data by using the binary data and structured data interchange method to store the third state data in the blockchain specifically includes:

[0019] Executing the smart contract of the blockchain through the second node, and responding to an update operation on the state data during the execution of the smart contract of the blockchain in the second node to update the second state data in the second node;

[0020] Call the serialization method to convert the updated second-state data into the third-state data, and write the third-state data into the blockchain storage in batches.

[0021] The system status loading method, wherein the serialization process of the serialization method specifically includes:

[0022] Get the data type of the status data;

[0023] An encoding method corresponding to the state data is determined according to the data type, and the state data is encoded according to the encoding method to obtain serialized state data.

[0024] The method for loading the system status, wherein determining the encoding method corresponding to the status data according to the data type specifically includes:

[0025] When the data type is a fixed-length type, the encoding method is to encode the status data using an encoding rule corresponding to the data type;

[0026] When the data type is not a fixed-length type, the encoding method is to recursively parse and encode the state data using an encoding structure.

[0027] The system status loading method, wherein the deserialization process of the deserialization method specifically includes:

[0028] Get the data type of the status data;

[0029] A parsing method for the state data is determined according to the data type, and the state data is parsed according to the parsing method to obtain serialized state data.

[0030] The method for loading the system status, wherein determining the parsing method of the status data according to the data type specifically includes:

[0031] When the data type is a fixed-length type, the parsing method is to convert the encoding rule corresponding to the data type into a little-endian mode;

[0032] When the data type is not a fixed-length type, the parsing method is to recursively parse the encoding structure corresponding to the data type.

[0033] In the method for loading the system status, the process of determining the encoding rule corresponding to the data type includes:

[0034] Read the byte width of the status data;

[0035] An encoding rule corresponding to the status data is selected according to the byte width, wherein the encoding rule includes a general encoding rule and a special processing rule.

[0036] A second aspect of the present application provides a system status loading system, wherein the system status loading system specifically includes:

[0037] A first conversion module is configured to convert the first state data in the first node into second state data by using an interchange method between binary data and structured data, so as to batch read the data into the second node, wherein the interchange method between binary data and structured data includes a deserialization method and a serialization method;

[0038] The second conversion module is configured to respond to an update operation on the second state data within the second node, and convert the updated second state data into third state data by using the binary data and structured data interchange method, for storage in the blockchain.

[0039] A third aspect of the present application provides a computer-readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps in any of the system status loading methods described above.

[0040] A fourth aspect of the present application provides a terminal device, comprising: a processor and a memory;

[0041] The memory stores a computer-readable program executable by the processor;

[0042] When the processor executes the computer-readable program, the processor implements the steps in any of the above-mentioned system status loading methods.

[0043] Beneficial effects: Compared with the prior art, the present application provides a method, system, device, and computer-readable storage medium for loading system status, the method comprising converting the first state data in the first node into the second state data through the interchange method between binary data and structured data, so as to be read in batches into the second node; responding to the update operation for the second state data in the second node, and converting the updated second state data into the third state data through the interchange method between binary data and structured data, so as to be stored in the blockchain. The present application loads the first state data into the second node in batches through the interchange method between binary data and structured data, and then writes the updated second state data into the first node and other nodes on the blockchain in batches through the interchange method between binary data and structured data. The status data is obtained in batches before the status data is updated, and is stored in batches after the status data is updated. There is no need to read and write the status data one by one, which avoids frequent access to the first node, improves execution efficiency and throughput, and also improves the management capability of the status data. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0045] Figure 1 A flowchart illustrating a method for loading status data of a smart contract in Ethereum provided in an embodiment of the present application.

[0046] Figure 2 A flowchart of a method for loading system status provided in an embodiment of the present application.

[0047] Figure 3 A flowchart of a specific example of inserting a data interaction protocol into a serialization method and a deserialization method.

[0048] Figure 4 The following is a sequence diagram of an example where the data interaction protocol is a smart contract.

[0049] Figure 5 This is a sequence diagram of the smart contract deployment process in an example where the data interaction protocol is a smart contract.

[0050] Figure 6 The following is a sequence diagram of the smart contract execution process in an example where the data interaction protocol is a smart contract.

[0051] Figure 7 The diagram is a diagram showing an example of a data interaction protocol being a data transmission protocol in a distributed database system.

[0052] Figure 8 This is a principle block diagram of the system status loading device provided in an embodiment of the present application.

[0053] Figure 9 This is a block diagram of the principles of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0054] The embodiments of the present application provide a method, system, device, and computer-readable storage medium for loading system status. To make the objectives, technical solutions, and effects of the present application more clear and explicit, the present application is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are intended only to explain the present application and are not intended to limit the present application.

[0055] It will be understood by those skilled in the art that, unless otherwise stated, the singular forms "a," "an," "said," and "the" used herein may also include the plural forms. It should be further understood that the term "comprising" used in the specification of this application refers to the presence of the stated features, integers, steps, operations, elements, and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.

[0056] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those skilled in the art to which this application belongs. It should also be understood that terms such as those defined in common dictionaries should be understood to have meanings consistent with their meanings in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless specifically defined as herein.

[0057] It should be understood that the sequence numbers and sizes of the steps in this embodiment do not imply the order of execution. The order of execution of each process is determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of this application.

[0058] Research has shown that blockchain smart contracts, as self-executing protocols, have been widely adopted in numerous fields. With the rapid development of blockchain technology, various smart contract platforms have proposed diverse smart contract execution models. Currently, the most widely adopted smart contract platforms convert state read operations in the contract code into SLOAD (load from storage) instructions and state write operations into SSTORE (write to storage) instructions. These instructions are executed one by one by the smart contract execution engine. Each read or write of state parameters requires the smart contract execution engine to operate on the stored state, consuming significant computing resources and resulting in high gas costs, which impacts the scalability of blockchain applications. Furthermore, frequent state data interactions increase storage access times and contract execution latency, further impacting smart contract execution efficiency and throughput.

[0059] For example, in the currently widely used Ethereum, its smart contracts are executed using EVM (Ethereum Virtual Machine, which is the execution engine of Ethereum’s smart contracts). Figure 1 As shown in the figure, Ethereum's smart contract compiler converts the state data reading operation in the contract code into SLOAD (load from storage) instructions, and converts the state data writing operation into SSTORE (write to storage) instructions. Then the smart contract execution engine executes each one when executing the smart contract, which requires the smart contract execution engine to frequently operate on the blockchain storage.

[0060] In order to solve the above problems, in an embodiment of the present application, the first state data in the first node is converted into the second state data through the interchange method between binary data and structured data, so as to be read in batches into the second node; in the second node, an update operation for the second state data is responded to, and the updated second state data is converted into the third state data through the interchange method between binary data and structured data, so as to be stored in the blockchain. The present application loads the first state data into the second node in batches through the interchange method between binary data and structured data, and then writes the updated second state data into the first node and other nodes on the blockchain in batches through the interchange method between binary data and structured data. The state data is obtained in batches before the state data is updated, and the state data is stored in batches after the state data is updated. There is no need to read and write the state data one by one, which improves the execution efficiency and throughput, and also improves the management capability of the state data.

[0061] The application content will be further explained below through description of embodiments in conjunction with the accompanying drawings.

[0062] This embodiment provides a method for loading system status, such as Figure 2 As shown, the method includes:

[0063] S10, converting the first state data in the first node into second state data by using a binary data and structured data interchange method, and reading the data in batches into the second node;

[0064] S20. Respond to an update operation on the second state data within the second node, and convert the updated second state data into third state data using the binary data and structured data interchange method, for storage in the blockchain.

[0065] Specifically, in step S10, the method for exchanging binary data with structured data includes a deserialization method and a serialization method. The deserialization method is used to convert binary data into structured data, and the serialization method is used to convert structured data into binary data. That is, when the first-state data is structured data, the deserialization method is used to convert it into the second-state data, which is binary data. Conversely, when the first-state data is binary data, the serialization method is used to convert it into the second-state data, which is structured data.

[0066] Furthermore, when converting the first-state data in the first node into the second-state data, the conversion method corresponding to the first-state data can be determined based on the data structure type of the first-state data. Specifically, the data structure type of the first-state data in the first node is first read. If the data structure type is binary data, the deserialization method is used as the conversion method corresponding to the first-state data; if the data structure type is structured, the serialization method is used as the conversion method corresponding to the first-state data.

[0067] Of course, in actual applications, other methods can also be used to determine the conversion method corresponding to the first state data, for example, the conversion method corresponding to the first state data is determined based on the data structure type of the first state data and the second state data. Specifically, the data structure type of the first state data and the data structure type of the second state data are obtained respectively. If the data structure type of the first state data and the data structure type of the second state data are different, the conversion method corresponding to the first state data is determined based on the data structure type of the first state data and the data structure type of the second state data; if the data structure type of the first state data and the data structure type of the second state data are the same, the data structure type required for data transmission between the first node and the second node is obtained, and the conversion method corresponding to the first state data is determined based on the data structure type of the first state data and the data structure type. For example, when the first state data is binary data and the second state data is structured data, the conversion method corresponding to the first state data is a deserialization method. When the first state data and the second state data are both structured data and the data structure type required for data transmission between the first node and the second node is binary data, the conversion method corresponding to the first state data is a serialization method.

[0068] In step S20, the update operation of the second state data is formed by executing the data interaction protocol on the second state data, and is used to update the state data. In other words, the modification of the state data generated by the execution of the data interaction protocol occurs and is updated in the second node. It can be understood that because the second state data in step S10 is state data obtained in batches, the embodiment of the present application does not need to read the state data from the first node multiple times when executing the data interaction protocol. Instead, the state data can be updated in batches after being obtained in batches.

[0069] Furthermore, after the data exchange protocol is executed, all updated second-state data is converted to third-state data using the binary data-structured data interchange method, so that all third-state data is written to the first node and other nodes of the blockchain at once. The conversion method corresponding to the second-state data is determined in the same manner as the first-state data and will not be further described here. Furthermore, it should be noted that the data structure type of the first-state data is different from the data structure type of the second-state data, and the data structure type of the first-state data is different from the data structure type of the third-state data.

[0070] The serialization method and deserialization method of the embodiment of the present application convert the first state data into the second state data and read it in batches into the second node. Then, after responding to the update operation for the state data in the second node, the updated second state data is converted into the third state data and written in batches to the first node. This realizes batch acquisition of state data before the state data is updated and batch storage of state data after the state data is updated, without the need to read and write state data one by one, thereby improving execution efficiency and throughput.

[0071] In one embodiment, the binary data and structured data interchange method is pre-inserted into the data interaction protocol between the first node and the second node, so that when the second node reads state data from the first node and writes state data to the first node, the binary data and structured data interchange method can be called to convert the first state data into the second state data and the updated second state data into the third state data. Based on this, before converting the first state data in the first node to the second state data using the binary data and structured data interchange method for batch reading into the second node, the method further includes:

[0072] Based on the instruction insertion technology, the interchange method between binary data and structured data is inserted into the data interaction protocol between blockchain nodes.

[0073] Specifically, instruction instrumentation technology is used to insert code instructions into a data interaction protocol, that is, to insert the method for exchanging binary data with structured data as code instructions into the data interaction protocol. The data interaction protocol is an interaction protocol between blockchain nodes, through which blockchain nodes can exchange state data. The data interaction protocol is one of a blockchain smart contract, a distributed database consistency protocol, and a distributed database data transmission protocol. For example, when the data interaction protocol is a blockchain smart contract, the data structure type of the first state data can be the data structure type required for blockchain storage, and the second state data can be the data structure type required by the smart contract's execution engine; when the data interaction protocol is a distributed database data transmission protocol, the data structure type of the first state data can be the data structure type required by the first node, and the data structure type of the second state data can be the data structure type required for data transmission between the first node and the second node.

[0074] Exemplarily, the data interaction protocol is a blockchain smart contract, which is deployed on the blockchain in the form of binary data interaction protocol bytecode. Therefore, the first state data in the first node is binary data, and the first state data is converted into structured data (i.e., second state data) through deserialization. Accordingly, the first state data in the first node is converted into the second state data through the binary data and structured data interchange method, and then batch read into the second node, specifically:

[0075] A deserialization method is called to convert the first state data in the first node into the second state data, and the second state data is read in batches into the second node.

[0076] Furthermore, after the second state data is read in batches into the second node, the smart contract is executed by the second node, and all update operations on the state data generated during the execution of the smart contract are executed in the second node. After the smart contract execution is completed, the second node calls the serialization method to convert the updated second state data into third state data, and then writes the converted third state data into the first node in batches. Based on this, the response to the update operation on the second state data in the second node and the conversion of the updated second state data into third state data using the binary data and structured data interchange method for storage on the blockchain specifically include:

[0077] Executing the smart contract of the blockchain through the second node, and responding to an update operation on the state data during the execution of the smart contract of the blockchain in the second node to update the second state data in the second node;

[0078] Call the serialization method to convert the updated second-state data into the third-state data, and write the third-state data into the blockchain storage in batches.

[0079] In one embodiment, the method for exchanging binary data with structured data based on instruction instrumentation technology is inserted into the data interaction protocol between blockchain nodes, specifically including:

[0080] In response to a compilation instruction for the data interaction protocol, compile the data interaction protocol by a compiler;

[0081] During the compilation process of the compiler, one of the serialization method and the deserialization method is inserted before the protocol business logic of the data interaction protocol through instruction insertion technology, and the other method is inserted after the protocol business logic of the data interaction protocol.

[0082] Specifically, the compilation instruction is used to trigger the compiler, which compiles the original code corresponding to the data interaction protocol into binary data interaction protocol bytecode that can be deployed on the blockchain. The serialization method and the deserialization method are inserted into the data interaction protocol during the compiler's compilation process, so that the compiled binary data interaction protocol bytecode contains the serialization method and the deserialization method.

[0083] Furthermore, during the compilation process of the compiler, the compiler can be modified so that the compiler first inserts one of the serialization method and the deserialization method before the compilation of the protocol business logic of the data interaction protocol through the instruction insertion technology, and then compiles the protocol business logic of the data interaction protocol. After the compilation of the protocol business logic of the data interaction protocol is completed, the compiler inserts the other of the serialization method and the deserialization method after the protocol business logic of the data interaction protocol through the instruction insertion technology.

[0084] For example: Figure 3 As shown, the protocol business logic of the data interaction protocol is input into the compiler. After obtaining the protocol business logic of the data interaction protocol, the compiler inserts a serialization method before the protocol business logic of the data interaction protocol through the instruction insertion technology, and inserts a deserialization method after the protocol business logic of the data interaction protocol through the instruction insertion technology to obtain a compiled data interaction protocol including a serialization method and a deserialization method. The compiled data interaction protocol is a binary data interaction protocol bytecode.

[0085] Furthermore, to enable serialization and deserialization methods to be callable by blockchain nodes, external blockchain nodes, and external devices, the deserialization and serialization methods can be inserted into the global functions of the smart contract, allowing both the first and second nodes to call the deserialization and serialization methods in the global functions to convert the first-state data into the second-state data, and to convert the updated second-state data into the third-state data. For example, when the data interaction protocol is a smart contract, the first-state data can be converted from binary data to structured data by calling the deserialization method in the global function, so that the first-state data can be read in batches into the memory of the smart contract's execution engine and stored in the memory of the smart contract's execution engine as second-state data. Then, after the business logic code of the smart contract is executed, the updated second-state data is converted from structured data to binary data and written in batches to the blockchain storage, thereby updating the first-state data in the blockchain storage with the third-state data. Blockchain storage is intended to persistently store various types of data on the blockchain, including contract code, contract state data, transaction records, and so on. Its core purpose is to ensure that this data can be reliably stored and shared throughout the blockchain network so that each node can verify, query and reach consensus, thereby ensuring the integrity of the blockchain ledger and the consistency of the data.

[0086] In addition, in order to further illustrate the above-mentioned method of loading state data, the method of loading state data is described by taking the data interaction protocol as a smart contract and the data transmission protocol of a distributed database as examples.

[0087] Example 1: The data interaction protocol is a smart contract, such as Figure 4 、 Figure 5 and Figure 6 As shown, the specific process of the state data loading method may be:

[0088] H10. Developers send smart contracts to the blockchain smart contract compiler;

[0089] H20. The blockchain smart contract compiler compiles the smart contract to obtain binary contract bytecode including a deserialization method, the contract business logic of the smart contract, and a serialization method. During the compilation process, the serialization method is first inserted before the contract business logic of the smart contract using instruction instrumentation technology, and the deserialization method is inserted after the contract business logic of the smart contract using instruction instrumentation technology. Both the deserialization method and the serialization method are located in the global function domain of the smart contract.

[0090] H30. The developer deploys the compiled binary contract bytecode to the blockchain;

[0091] H40. The user initiates a business request to the smart contract on the blockchain. The business request is encapsulated into a transaction on the blockchain and placed into the blockchain transaction pool.

[0092] H50. After the transactions in the blockchain transaction pool are packaged and uploaded to the blockchain, they enter the blockchain's smart contract execution engine for execution;

[0093] H60. When executing a smart contract, the smart contract execution engine first calls the deserialization processing method to pre-load the state time of the smart contract stored in the blockchain storage into the memory of the smart contract execution engine at one time;

[0094] H70, the smart contract execution engine executes the contract business logic code and responds to state data modification operations in the smart contract execution engine;

[0095] H80. After the smart contract is executed, the smart contract execution engine calls the serialization processing method to write the modified smart contract status data into the blockchain storage in batches, and stores it persistently on the blockchain in an efficient batch writing manner.

[0096] In this example, deserialization and serialization methods are pre-installed in the smart contract's global functions. Before the smart contract is executed, the deserialization method is used to preload the first state data from the blockchain storage into the memory of the smart contract's execution engine. The smart contract's execution engine responds to state data updates during the smart contract's execution to update the second state data within the smart contract's execution engine. After the smart contract completes, the serialization method is used to convert the updated second state data in the smart contract's execution engine into third state data for batch writing to the blockchain storage. This eliminates the need for multiple read and write operations to the blockchain storage, reduces the computing resources consumed by executing the smart contract, and improves smart contract execution efficiency.

[0097] Example 2: The data interaction protocol is a distributed database data transmission protocol, such as Figure 7 As shown, the specific process of the state data loading method may be:

[0098] M10. Insert serialization and deserialization methods into the front and back ends of the distributed database data transmission protocol through the instrumentation technology.

[0099] M20. The first node converts the initial structured data (first state data) into a binary data stream (i.e., second state data) through a serialization method.

[0100] M30. The first node broadcasts the binary data stream on the network so that the second node receives the binary data stream;

[0101] M40. After receiving the binary data stream, the second node responds to the update operation on the binary data stream, converts the updated binary data stream into updated structured data (third state data) through a deserialization method, and stores the updated structured data.

[0102] In this example, a deserialization method and a serialization method are pre-inserted into the data transmission protocol of the distributed database. The initial structured data is first converted into a binary data stream through the serialization method, and then the binary data stream is batch-transmitted to the second node through broadcasting. After receiving the binary stream data, the second node responds to the update operation for the binary stream data, and after the update is completed, the binary data stream is converted into structured data in the local memory through the deserialization method.

[0103] In one embodiment, the serialization process of the serialization method specifically includes:

[0104] Get the data type of the status data;

[0105] An encoding method corresponding to the state data is determined according to the data type, and the state data is encoded according to the encoding method to obtain serialized state data.

[0106] Specifically, data types are a way of classifying and constraining data in computer programming, which can determine how data is stored, how it is operated, and how memory is allocated. Data types can be divided into basic data types and composite data types based on whether the data length is fixed. Basic data types have a fixed data length, while composite data types have a variable data length. For example, basic data types may include, but are not limited to:

[0107] bool: Boolean type (1 bit);

[0108] int <m>: 2^M-bit signed integer (3≤M≤9), for example: int8, int128, int512, etc.;

[0109] uint <m>: 2^M-bit unsigned integer (3≤M≤9), for example: uint8, uint128, uint512, etc.;

[0110] float <n>: N-bit floating point number (N=256 / 512 / 1024), for example float256, float512;

[0111] blob: data block summary (32 bytes);

[0112] hash: hash value (32 bytes);

[0113] address: address (36 bytes).

[0114] Composite data types can include, but are not limited to:

[0115] array <t>: array type;

[0116] map<K,V> : mapping type;

[0117] string: string type;

[0118] bigint: large integer type;

[0119] struct: structure type.

[0120] Furthermore, since the data length of the basic data type is fixed while the data length of the composite data type is not fixed, different encoding methods can be configured for the basic data type and the composite data type. In other words, the encoding method corresponding to the status data can be determined based on whether the data type is a basic data type or a composite data type. Based on this, the encoding method corresponding to the status data determined based on the data type specifically includes:

[0121] When the data type is a fixed-length type, the encoding method is to encode the status data using an encoding rule corresponding to the data type;

[0122] When the data type is not a fixed-length type, the encoding method is to recursively parse and encode the state data using an encoding structure.

[0123] Specifically, encoding rules are rules for converting first-state data into second-state data. These rules include general encoding rules and special processing rules. General encoding rules are used to convert the first-state data, while special processing rules are the constraints imposed by the general encoding rules when encoding. The encoding structure is used to decompose the first-state data into its structure, and then recursively parse and encode the resulting structure.

[0124] In one embodiment, the process of determining the encoding rule corresponding to the data type includes:

[0125] Read the byte width of the status data;

[0126] An encoding rule corresponding to the status data is selected according to the byte width.

[0127] Specifically, the byte width refers to the data length of the state data. After obtaining the byte width of the state data, an encoding rule can be selected for the state data based on the byte width. The encoding rule is used to encode and serialize the state data into a binary data stream. In other words, by encoding the state data according to the encoding rule, the state data can be serialized from a structured data type to binary data. Among them, since the byte widths of the data types belonging to the basic data types are different, each data type belonging to the basic data type can also correspond to a different encoding rule. Each data type belonging to the basic data type has a different encoding rule that can be pre-set based on the byte width. For example, the encoding rules corresponding to each data type included in the basic data type are shown in Table 1.

[0128] Table 1 Encoding rules corresponding to each data type in the basic data type

[0129]

[0130] Furthermore, each data type belonging to the composite data type may be pre-set with a coding structure. For example, the coding structures corresponding to the data types included in the composite data type are shown in Table 2.

[0131] Table 2 Coding structure corresponding to each data type in the composite data type

[0132]

[0133] In one embodiment, the deserialization process of the deserialization method specifically includes:

[0134] Get the data type of the status data;

[0135] A parsing method for the state data is determined according to the data type, and the state data is parsed according to the parsing method to obtain serialized state data.

[0136] Specifically, when deserializing using the deserialization method, similar to serialization using the serialization method, the data type of the state data is first obtained, and then a parsing method for the state data is determined based on the data type of the state data. The state data is then parsed according to the parsing method to obtain serialized state data. The parsing method for the state data can also be determined based on whether the data type of the state data is a basic data type or a composite data type.

[0137] Exemplarily, determining the parsing method of the status data according to the data type specifically includes:

[0138] When the data type is a fixed-length type, the parsing method is to convert the encoding rule corresponding to the data type into a little-endian mode;

[0139] When the data type is not a fixed-length type, the parsing method is to recursively parse the encoding structure corresponding to the data type.

[0140] Specifically, when the data type of the status data belongs to a basic data type, the little-endian mode conversion is performed according to the encoding rules corresponding to the data type of the status data to convert it into the data state of a structured data type. When the data type of the status data belongs to a composite data type, the encoding structure corresponding to the data type can be recursively parsed to convert it into the data state of a structured data type. Among them, the parsing process and the encoding process are mutually inverse processes, and the status data can be parsed according to the encoding rules adopted in the encoding process through parsing. That is to say, the status data of the structured data type can be converted into the status data of the binary data type through the encoding process in the serialization method, and the status data of the binary data type can be converted into the status data of the structured data type through the parsing process in the deserialization method. At the same time, the status data of the binary data type can be converted into the status data of the structured data type through the parsing process in the deserialization method, and the status data of the structured data type can be converted into the status data of the binary data type through the encoding process in the serialization method.

[0141] Furthermore, the corresponding encoding rules for little-endian mode conversion refer to converting the state data according to the encoding rules, wherein the conversion process may include little-endian mode conversion, data type check and value domain verification. That is to say, the state data is parsed according to the encoding rules corresponding to the data type of the state data. Specifically, the first state data may be converted to little-endian mode according to the encoding rules, and then the data type check and value domain verification may be performed on the converted state data. When the data type check and value domain verification are passed, the converted state data is used as the second state data after serialization of the first state data. Of course, when the data type check and / or value domain verification fail, a parsing error may be prompted, or the first state data may be marked as a parsing error, and then the unparsed first state data may be parsed.

[0142] Based on the above system status loading method, this embodiment provides a system status loading system, such as Figure 8 As shown, the system status loading system specifically includes:

[0143] A first conversion module 100 is configured to convert the first state data in the first node into second state data by using a binary data to structured data interchange method, so as to batch read the data into the second node, wherein the binary data to structured data interchange method includes a deserialization method and a serialization method;

[0144] The second conversion module 200 is configured to respond to an update operation on the second state data within the second node, and convert the updated second state data into third state data through the binary data and structured data interchange method, for storage in the blockchain.

[0145] Based on the above-mentioned system status loading method, this embodiment provides a computer-readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps in the system status loading method as described in the above-mentioned embodiment.

[0146] Based on the above system status loading method, the present application also provides a terminal device, such as Figure 9 As shown, it includes at least one processor 20; a display screen 21; and a memory 22. It may also include a communications interface 23 and a bus 24. The processor 20, display screen 21, memory 22, and communications interface 23 can communicate with each other via bus 24. The display screen 21 is configured to display a preset user guidance interface in the initial setup mode. The communications interface 23 can transmit information. The processor 20 can invoke logic instructions in the memory 22 to execute the method described in the above embodiment.

[0147] In addition, the logic instructions in the memory 22 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.

[0148] The memory 22, as a computer-readable storage medium, can be configured to store software programs or computer-executable programs, such as program instructions or modules corresponding to the methods in the embodiments of the present disclosure. The processor 20 executes the software programs, instructions, or modules stored in the memory 22 to perform functional applications and data processing, thereby implementing the methods in the above embodiments.

[0149] The memory 22 may include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function; the data storage area may store data created based on the use of the terminal device. In addition, the memory 22 may include high-speed random access memory and non-volatile memory. For example, various media that can store program code, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, may also be transient storage media.

[0150] In addition, the specific process of loading and executing the multiple instructions in the storage medium and the processor in the terminal device has been described in detail in the above method and will not be described here one by one.

[0151] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.< / t> < / n> < / m> < / m>

Claims

1. A method for loading a system state, characterized in that: The method for loading the system status specifically includes: Converting the first state data in the first node into the second state data by using a binary data and structured data interchange method, so as to batch read the data into the second node, wherein the binary data and structured data interchange method includes a deserialization method and a serialization method; Responding to an update operation on the second state data within the second node, converting the updated second state data into third state data using the binary data and structured data interchange method, and storing the data in an efficient batch write manner on the blockchain; Before converting the first state data in the first node into the second state data by using the binary data and structured data interchange method for batch reading into the second node, the method further includes: Inserting the binary data and structured data interchange method into a data interaction protocol between blockchain nodes based on instruction instrumentation technology, wherein the data interaction protocol is a smart contract of the blockchain; The method of inserting the binary data and structured data interchange method into the data interaction protocol between blockchain nodes based on the instruction instrumentation technology specifically includes: In response to a compilation instruction for the data interaction protocol, compile the data interaction protocol by a compiler; During the compilation process of the compiler, one of the serialization method and the deserialization method is inserted before the protocol business logic of the data interaction protocol through instruction insertion technology, and the other method is inserted after the protocol business logic of the data interaction protocol, wherein the serialization method and the deserialization method are inserted into the global function of the data interaction protocol.

2. The method for loading system status according to claim 1, characterized in that: The deserialization method is used to convert binary data into structured data, and the serialization method is used to convert structured data into binary data.

3. The method for loading system status according to claim 1, characterized in that: The data interaction protocol is a smart contract of the blockchain; The first state data in the first node is converted into the second state data by using the interchange method between binary data and structured data, so as to be read into the second node in batches, specifically: Calling a deserialization method to convert the first state data in the first node into the second state data, and reading the second state data in batches into the second node; The responding to the update operation for the second state data in the second node and converting the updated second state data into third state data by using the binary data and structured data interchange method to store the third state data in the blockchain specifically includes: Executing the smart contract of the blockchain through the second node, and responding to an update operation on the state data during the execution of the smart contract of the blockchain in the second node to update the second state data in the second node; Call the serialization method to convert the updated second-state data into the third-state data, and write the third-state data into the blockchain storage in batches.

4. The method for loading system status according to claim 1, characterized in that: The serialization process of the serialization method specifically includes: Get the data type of the status data; An encoding method corresponding to the state data is determined according to the data type, and the state data is encoded according to the encoding method to obtain serialized state data.

5. The method for loading system status according to claim 4, characterized in that: Determining the encoding method corresponding to the status data according to the data type specifically includes: When the data type is a fixed-length type, the encoding method is to encode the status data using an encoding rule corresponding to the data type; When the data type is not a fixed-length type, the encoding method is to recursively parse and encode the state data using an encoding structure.

6. The method for loading system status according to claim 5, characterized in that: The deserialization process of the deserialization method specifically includes: Get the data type of the status data; A parsing method for the state data is determined according to the data type, and the state data is parsed according to the parsing method to obtain serialized state data.

7. The method for loading system status according to claim 6, characterized in that: The method of determining the parsing method of the status data according to the data type specifically includes: When the data type is a fixed-length type, the parsing method is to convert the encoding rule corresponding to the data type into a little-endian mode; When the data type is not a fixed-length type, the parsing method is to recursively parse the encoding structure corresponding to the data type.

8. The method for loading system status according to claim 5 or 7, characterized in that: The process of determining the encoding rule corresponding to the data type includes: Read the byte width of the status data; An encoding rule corresponding to the status data is selected according to the byte width, wherein the encoding rule includes a general encoding rule and a special processing rule.

9. A system status loading system, characterized in that: The system status loading system specifically includes: A first conversion module is configured to convert the first state data in the first node into second state data by using an interchange method between binary data and structured data, so as to batch read the data into the second node, wherein the interchange method between binary data and structured data includes a deserialization method and a serialization method; A second conversion module is configured to respond to an update operation on the second state data within the second node, convert the updated second state data into third state data using the binary data and structured data interchange method, and store the data in an efficient batch write manner on the blockchain; Before converting the first state data in the first node into the second state data by using the binary data and structured data interchange method for batch reading into the second node, the method further includes: Inserting the binary data and structured data interchange method into a data interaction protocol between blockchain nodes based on instruction instrumentation technology, wherein the data interaction protocol is a smart contract of the blockchain; The method of inserting the binary data and structured data interchange method into the data interaction protocol between blockchain nodes based on the instruction instrumentation technology specifically includes: In response to a compilation instruction for the data interaction protocol, compile the data interaction protocol by a compiler; During the compilation process of the compiler, one of the serialization method and the deserialization method is inserted before the protocol business logic of the data interaction protocol through instruction insertion technology, and the other method is inserted after the protocol business logic of the data interaction protocol, wherein the serialization method and the deserialization method are inserted into the global function of the data interaction protocol.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps in the system status loading method according to any one of claims 1 to 8.

11. A terminal device, characterized in that: include: processor and memory; The memory stores a computer-readable program executable by the processor; When the processor executes the computer-readable program, the processor implements the steps in the method for loading the system status according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Data processing method and device based on smart contract and related equipment

    CN116680729A

  • Transaction processing method and device based on block chain system, and related equipment

    CN117011033A