Data processing method and device of block chain, electronic equipment and readable storage medium
By sending data synchronization requests to multiple nodes in the blockchain network and updating requests based on reputation value, the data synchronization efficiency and stability problems are solved, and more efficient data transmission and acquisition are achieved.
Patent Information
- Application Number
- CN202310655519.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-02
- Publication Date
- 2024-12-03
AI Technical Summary
In blockchain networks, data synchronization efficiency and stability are poor, especially when network fluctuations or node abnormalities, which may cause the data synchronization speed to be much lower than the new data writing speed, and even data synchronization cannot be completed.
By sending data synchronization requests to multiple blockchain network nodes and updating synchronization requests based on the reputation value returned by the node, the data synchronization process is optimized to ensure that the data synchronization is synchronized with high reputation nodes, reducing network communication consumption and improving data transmission speed.
It improves the stability and efficiency of the data synchronization process, avoids the abortion or inability to perform data synchronization caused by node abnormalities, reduces network communication consumption for multiple requests, and improves the transmission and acquisition speed of data synchronization.
Smart Images

Figure CN119066121A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a blockchain data processing method, device, electronic device and readable storage medium. Background Art
[0002] In a blockchain network, every piece of data must be agreed upon before it can be written to the blockchain. During this process, the data written by each node must remain consistent. Nodes with outdated data or that need to be updated need to initiate data synchronization requests to other nodes.
[0003] However, the requesting node needs to accurately calculate the data to be synchronized, and then send a request to the consensus node to obtain the data to be synchronized. During this period, the efficiency and stability of data synchronization may be poor due to network fluctuations or node anomalies. Especially in a blockchain network with a long running time or very high data writing efficiency, if the amount of data requested by the requesting node to synchronize is large, the speed of data synchronization may even be much lower than the speed of writing new data to the blockchain network, resulting in the inability to complete data synchronization. Summary of the invention
[0004] The embodiments of the present application provide a blockchain data processing method, device, system, electronic device and readable storage medium, which can improve the efficiency and stability of data synchronization operations on nodes of a blockchain network.
[0005] A first aspect of an embodiment of the present application provides a blockchain data processing method, the method being executed by a first node of a blockchain network, comprising:
[0006] Sending a data synchronization request to multiple second nodes of the blockchain network;
[0007] Receiving the synchronized data slices returned by each second node according to the data synchronization request, and the reputation value of each second node, wherein the reputation value represents the stable state of the synchronized data returned by the second node;
[0008] updating the data synchronization request and the second node for processing the updated data synchronization request according to the reputation value of each second node;
[0009] Receiving the updated synchronization data fragment returned by each of the updated second nodes according to the updated data synchronization request;
[0010] Assembling the updated synchronization data fragments to obtain complete synchronization data;
[0011] The synchronization data is written into the blockchain network to synchronize the data of the second node to the first node.
[0012] Accordingly, a second aspect of an embodiment of the present application provides a data processing method of a blockchain, the method being executed by a second node of a blockchain network, the method comprising:
[0013] Receiving a data synchronization request sent by a first node of the blockchain network, and determining synchronization data to be sent to the first node;
[0014] According to the data synchronization request, the synchronization data is fragmented to obtain a plurality of synchronization data fragments;
[0015] Determine a synchronization data segment to be sent from the multiple synchronization data segments;
[0016] The synchronization data slices are continuously sent to the first node, so that the first node obtains complete synchronization data based on the synchronization data slices.
[0017] Accordingly, a third aspect of an embodiment of the present application provides a data processing device for a blockchain, the device being applied to a first node of a blockchain network, the device comprising:
[0018] A request sending unit, configured to send a data synchronization request to a plurality of second nodes of the blockchain network;
[0019] A shard receiving unit, configured to receive the synchronized data shards returned by each second node according to the data synchronization request, and a reputation value of each second node, wherein the reputation value represents a stable state of the synchronized data returned by the second node;
[0020] a data updating unit, configured to update the data synchronization request according to the reputation value of each second node, and a second node configured to process the updated data synchronization request;
[0021] An updated data receiving unit, configured to receive updated synchronization data fragments returned by each of the updated second nodes according to the updated data synchronization request;
[0022] A fragment assembly unit, used for assembling the updated synchronization data fragments to obtain complete synchronization data;
[0023] A data writing unit is used to write the synchronization data into the blockchain network to synchronize the data of the second node to the first node.
[0024] Optionally, the blockchain data processing device further includes:
[0025] A node information receiving unit, configured to receive node information sent by a plurality of second nodes, wherein the node information includes a name and a block height of a corresponding second node;
[0026] A data synchronization protocol configuration unit, configured to configure a data synchronization protocol according to the node information, wherein the data synchronization protocol is used to define a second node that performs a data synchronization operation for the first node, and an execution logic of the data synchronization operation;
[0027] A protocol generating unit is used to add the data synchronization protocol to the request message of the first node to generate the data synchronization request.
[0028] Optionally, the data synchronization protocol configuration unit is further specifically used for:
[0029] Acquire a connectable second node according to the node information;
[0030] Obtain a shard index corresponding to the connectable second node, wherein the shard index is an index value of the synchronization data shard;
[0031] The data synchronization protocol is generated by taking the block height of the first node, the number of the second nodes to be connected, and the shard index corresponding to the connectable second nodes as protocol content.
[0032] Optionally, the data updating unit includes:
[0033] A reputation value calculation subunit, configured to calculate the reputation value of each second node according to the received synchronization data fragments or the state of each second node when sending data;
[0034] A list updating subunit, configured to update a locally stored second node list according to the reputation value of each second node, to obtain an updated second node list, wherein the second node list includes second nodes capable of data synchronization;
[0035] The request modification subunit is used to modify the data synchronization request according to the updated second node list.
[0036] Optionally, the reputation value calculation subunit is further specifically used for:
[0037] Obtaining the accuracy corresponding to the received synchronization data slice;
[0038] Acquire abnormal behavior of each second node when sending data;
[0039] Based on the accuracy or the abnormal behavior, the current reputation value of each second node is periodically adjusted to obtain the reputation value of each second node.
[0040] Optionally, the list updating subunit is further specifically used for:
[0041] Get the abnormal threshold of reputation value;
[0042] When the reputation value of any second node in the second node list is less than the abnormal threshold, the second node is determined as a pending abnormal node;
[0043] Obtaining a first observation time duration during which the reputation value of the pending abnormal node is continuously less than the abnormal threshold;
[0044] If the first observation duration is greater than a duration threshold, the pending abnormal node is determined as an abnormal node, and the abnormal node is deleted from the second node list.
[0045] Optionally, the blockchain data processing device further includes:
[0046] a pending abnormal node determining unit, configured to determine the pending abnormal node as a pending normal node if the first observation duration is less than a duration threshold and the reputation value of the pending abnormal node is restored to be greater than the abnormal threshold;
[0047] A second observation duration acquisition unit, used to acquire a second observation duration during which the reputation value of the pending normal node is continuously greater than the abnormal threshold;
[0048] A normal node determination unit is configured to determine the pending normal node as a normal node and retain the normal node in the second node list if the second observation duration is greater than the duration threshold.
[0049] Optionally, the request modification unit is further specifically configured to:
[0050] Obtaining the second nodes that are added or deleted in the updated second node list compared to the second node list;
[0051] According to the node information of the newly added or deleted second node, the node information carried in the data synchronization request is modified, wherein the node information includes the name, quantity, shard index and block height of the node, and the shard index is the index value of the synchronized data shard.
[0052] Accordingly, a fourth aspect of an embodiment of the present application provides a data processing device of a blockchain, the device being applied to a second node of a blockchain network, the device comprising:
[0053] A request receiving unit, configured to receive a data synchronization request sent by a first node of the blockchain network, and determine synchronization data to be sent to the first node;
[0054] A shard processing unit, configured to perform shard processing on the synchronization data according to the data synchronization request to obtain a plurality of synchronization data shards;
[0055] A fragment screening unit, used for determining a synchronization data fragment to be sent from the multiple synchronization data fragments;
[0056] A shard sending unit is used to continuously send the synchronization data shard and the corresponding reputation value to the first node, so that the first node obtains complete synchronization data based on the synchronization data shard, or based on the updated synchronization data shard obtained based on the reputation value, wherein the reputation value represents the stable state of the synchronization data returned by the second node.
[0057] Optionally, the data synchronization request carries a data synchronization protocol, wherein the data synchronization protocol includes the number of second nodes participating in data synchronization and protocol content of the block height of the first node;
[0058] The shard processing unit is further specifically used for:
[0059] Grouping the synchronization data, wherein each group of synchronization data includes data of at least one block;
[0060] Taking the number of the second nodes as the number of shards, sharding each group of synchronization data to obtain a data body of multiple shards;
[0061] Obtaining a data header with information about the group in which the data body is located;
[0062] The multiple data bodies are concatenated with corresponding data headers to obtain the multiple synchronous data fragments.
[0063] Optionally, the synchronization data is sent in a target number of sending rounds;
[0064] The fragment sending unit is further specifically used for:
[0065] In the current sending round, the synchronous data slices belonging to the current sending round are sent to the first node to complete the data sending operation of the current sending round;
[0066] In the remaining sending rounds, the data sending operation is repeatedly performed until the data sending operations of the target number of sending rounds are completed.
[0067] A fifth aspect of an embodiment of the present application provides an electronic device, including:
[0068] Processors and storage media;
[0069] The processor is used to implement each instruction;
[0070] The storage medium is used to store a plurality of instructions, and the instructions are used to be loaded by a processor and execute the blockchain data processing method described above.
[0071] The sixth aspect of the embodiments of the present application further provides a readable storage medium, which stores multiple instructions, and the instructions are suitable for a processor to load to execute the steps in any blockchain data processing method provided in the embodiments of the present application.
[0072] The seventh aspect of the embodiments of the present application also provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements any blockchain data processing method provided in the embodiments of the present application.
[0073] It can be seen from this that, by applying the embodiments of the present application, the first node requesting data synchronization can send data synchronization requests to multiple second nodes participating in the consensus mechanism, and obtain complete synchronized data based on the splicing of multiple synchronized data fragments returned by the multiple second nodes.
[0074] In the above manner, the first node sends a data synchronization request to multiple second nodes. When each second node returns its own synchronization data fragment, it also returns a corresponding reputation value, so that the first node can judge the stability of the data returned by each second node based on the reputation value, and by updating the data synchronization request and the second node with high reputation, it can avoid the situation where the entire data synchronization process is terminated or cannot be carried out due to anomalies in the second node, thereby improving the stability of the data synchronization process. And by each second node returning the corresponding synchronization data fragment to the first node, until the first node obtains complete synchronization data based on all synchronization data fragments, it can reduce the network communication consumption of multiple data synchronization requests, improve the speed of transmission and acquisition of synchronization data, and thus effectively improve the efficiency of the data synchronization process. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0076] Figure 1 It is a schematic diagram of an application scenario of a blockchain data processing system provided in an embodiment of the present application;
[0077] Figure 2a It is a flowchart of the data processing method of the blockchain provided in the embodiment of the present application;
[0078] Figure 2b It is a flowchart of the data processing method of the blockchain provided in the embodiment of the present application;
[0079] Figure 2c It is a flowchart of the data processing method of the blockchain provided in the embodiment of the present application;
[0080] Figure 2d It is a flowchart of the data processing method of the blockchain provided in the embodiment of the present application;
[0081] Figure 3a is a schematic diagram of splicing synchronous data slices to obtain synchronous data provided by an embodiment of the present application;
[0082] Figure 3b It is a structural diagram of synchronous data sharding and each group of synchronous data provided in an embodiment of the present application;
[0083] Figure 3c It is a schematic diagram of a data synchronization protocol based on node information configuration provided in an embodiment of the present application;
[0084] Figure 3d is a schematic diagram of updating the second node list based on node information provided by an embodiment of the present application;
[0085] Figure 3e It is a schematic diagram of determining normal nodes and abnormal nodes provided by an embodiment of the present application;
[0086] Figure 3f is a schematic diagram of modifying a data synchronization protocol provided in an embodiment of the present application;
[0087] Figure 4a It is a structural schematic diagram of a blockchain data processing device provided in an embodiment of the present application;
[0088] Figure 4b It is a structural schematic diagram of a blockchain data processing device provided in an embodiment of the present application;
[0089] Figure 5 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0090] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0091] The embodiments of the present disclosure are applied to blockchain technology. For example, the system involved in the embodiments of the present disclosure may be a system formed by connecting a client and multiple blockchain nodes (any form of computing devices in the access network, such as a server and a user terminal) through network communication.
[0092] See also Figure 1 , Figure 1 It is a schematic diagram of an application scenario of a blockchain data processing system provided in an embodiment of the present application. The system may include a blockchain network and a client, wherein the blockchain network may include multiple blockchain nodes (also referred to as nodes for short, which may be any form of computing device connected to the network, such as a server, a user terminal).
[0093] In specific application scenarios, such as Figure 1 As shown, taking the first node and the second node in the blockchain network as an example, it is assumed that the data of the first node lags behind the second node. For example, the first node includes data stored in two blocks, block 1 and block 2, and the second node includes data stored in three blocks, block 1, block 2 and block 3. Therefore, the first node can initiate a data synchronization request to the second node to request the second node to synchronize the data stored in block 3 to the first node. This process is also called "block synchronization", that is, requesting the second node to synchronize block 3 to the first node. After the first node obtains the data of block 3, it can block 3, that is, write the data corresponding to block 3 into the local storage of the blockchain network. Each block contains certain transaction data and metadata (such as block hash value, timestamp, etc.). After these data are packaged into a block and confirmed by the consensus algorithm, they will be written into the blockchain and become part of the chain data structure that cannot be tampered with. Therefore, writing data into the blockchain can also be understood as putting data on the chain to complete the entire data synchronization operation.
[0094] exist Figure 1 In the system shown, the client can send a transaction request to a consensus node or a master node among the nodes through the network. The master node is a consensus node selected from the consensus nodes to package transactions into blocks and broadcast the proposal of the block to other consensus nodes.
[0095] The network used by the client to send the transaction request may be a wireless network or a wired network using standard communication technology and / or protocols. The network is usually the Internet, but it may also be any network, including but not limited to a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), a mobile, wired or wireless network, a dedicated network or any combination of a virtual private network. In some embodiments, technologies and / or formats including Hyper Text Mark-up Language (HTML), Extensible Markup Language (XML), etc. are used to represent data exchanged over the network. In addition, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), Internet Protocol Security (IPsec), etc. may be used to encrypt all or some links. In other embodiments, customized and / or dedicated data communication technologies may also be used to replace or supplement the above data communication technologies.
[0096] The client may be an electronic device capable of sending transaction requests to a consensus node or a master node. The electronic device may be a smart phone, a computer, a server, etc., and the embodiments of the present disclosure do not impose any restrictions on this.
[0097] It should be noted that the order of description of the following embodiments is not intended to limit the priority order of the embodiments.
[0098] A data processing method for a blockchain, the method being executed by a first node of a blockchain network, comprising: sending a data synchronization request to multiple second nodes of the blockchain network; receiving a synchronization data shard returned by each second node according to the data synchronization request, and a reputation value of each second node, wherein the reputation value represents a stable state of the synchronization data returned by the second node; updating the data synchronization request and a second node for processing the updated data synchronization request according to the reputation value of each second node; receiving an updated synchronization data shard returned by each updated second node according to the updated data synchronization request; assembling the updated synchronization data shards to obtain complete synchronization data; and writing the synchronization data into the blockchain network to synchronize the data of the second node to the first node.
[0099] A data processing method for a blockchain, the method being executed by a second node of a blockchain network, the method comprising: receiving a data synchronization request sent by a first node of the blockchain network, and determining synchronization data to be sent to the first node; sharding the synchronization data according to the data synchronization request to obtain a plurality of synchronization data shards; determining a synchronization data shard to be sent from the plurality of synchronization data shards; and continuously sending the synchronization data shards to the first node, so that the first node obtains complete synchronization data based on the synchronization data shards.
[0100] See also Figure 2a In this embodiment, a blockchain data processing method is provided, which is executed by a first node in a blockchain network, such as Figure 2a As shown, the specific process of the data processing method of the blockchain can be as follows:
[0101] Step 101: Send a data synchronization request to multiple second nodes of the blockchain network.
[0102] according to Figure 1 From the description of the data synchronization scenario of the blockchain network, it can be seen that there may be a first node in the blockchain network whose data is outdated or needs to be updated. For example, when there is a "new node joining the blockchain network, a fork in the blockchain network, a node reconnecting after being offline for a long time, a blockchain network upgrade, a node's database is damaged or data is lost and needs to be reconstructed", there will be a first node in the blockchain network that needs to synchronize data.
[0103] Among them, the second node can be a consensus node in the blockchain network. The consensus node refers to a node that participates in the blockchain consensus mechanism, which is used to verify and package new transactions in the blockchain network, generate new blocks, and participate in the consensus process of the blockchain. Therefore, the first node needs to initiate a data synchronization request to the second node, and generate a block of the latest data in the blockchain network in the first node to fill the data that lags behind other nodes.
[0104] In some embodiments, the second node may also be a super node with a higher authority level among the consensus nodes. Super nodes are usually more credible among the consensus nodes and usually have more voting rights in the blockchain network. For example, the second node may be set with a higher initial authority level or obtain a higher authority certification.
[0105] In some embodiments, the first node may send a data synchronization request to multiple second nodes. On the one hand, through the method of the present application, multiple second nodes may cooperate with each other to send their respective corresponding synchronization data to the first node to achieve efficient data synchronization operation. On the other hand, the information of multiple second nodes may be compared to determine whether the data of each second node is the latest, and it may also be possible to avoid the inability to respond to data synchronization requests or interruption of the data synchronization process due to an abnormality of a second node.
[0106] It should be noted that the second node in this application is usually a node that stores the latest data in the blockchain network, so that it can perform accurate data synchronization operations on the first node. When the second node lags behind or needs to be updated due to the above "fork in the blockchain network, reconnection of the node after a long period of offline, blockchain network upgrade, database damage or data loss of the node needs to be reconstructed", its identity can also be converted to the first node. In addition, the specific number of second nodes that receive data synchronization requests is not limited in this embodiment.
[0107] Before step 101, the method of the present application further includes:
[0108] Receiving node information sent by multiple second nodes, wherein the node information includes a name and a block height of the corresponding second node;
[0109] According to the node information, configure a data synchronization protocol, wherein the data synchronization protocol is used to define a second node that performs a data synchronization operation for the first node, and an execution logic of the data synchronization operation;
[0110] The data synchronization protocol is added to the request message of the first node to generate the data synchronization request.
[0111] See also Figure 3c and Figure 3d , Figure 3c is a schematic diagram of a data synchronization protocol based on node information configuration provided in an embodiment of the present application, Figure 3d It is a schematic diagram of updating the second node list based on node information provided in an embodiment of the present application.
[0112] In some embodiments, the first node can receive node information sent by multiple second nodes through the node manager. Among them, the node manager is a component that each node in the blockchain network has, and the node manager includes two subcomponents: a node information collector and a node information broadcaster. The node information collector is used to receive node information from the network and store it in the local node manager. This node information includes information such as the IP address, port number, version number, block height, etc. of other nodes, which can help the node understand the topology of the entire network and the status of each node. The node information broadcaster is used to broadcast the information of this node to the network, including the node's IP address, port number, version number, block height, etc. In this way, other nodes can understand the status of this node in a timely manner and establish connections with it as needed.
[0113] In the node manager, some important information is also maintained, such as the synchronized block height, pending transactions, current consensus status, etc., as well as the corresponding task queue. The node manager is also responsible for obtaining the operating status of the entire node and automatically performing some operations when necessary, such as resynchronizing blocks, updating consensus status, etc.
[0114] In some embodiments, the node information of the second node may include the name and block height of the second node, wherein the name of the second node may be distinguished by the IP address, port number, and version number. Figure 3d As shown, the second node can broadcast its own node information to the blockchain network at regular intervals based on its own node information broadcaster. Correspondingly, the node receiver of the first node can receive the node information of the second node in the blockchain network and cache the node information in the node manager.
[0115] In some embodiments, the data synchronization request may carry a corresponding data synchronization protocol. Among them, the data synchronization protocol can be used to help the first node and the second node establish a handshake connection. It can be understood that the method of the present application can be implemented by sending corresponding synchronization data fragments to the first node through multiple consensus nodes. Therefore, the content of the data synchronization protocol can define which second nodes perform data synchronization operations for the first node, as well as the execution logic of the data synchronization operation. Add the written data synchronization protocol to the request of the first node to generate a data synchronization request with the data synchronization protocol.
[0116] It should be noted that, unlike the connection establishment of TCP (Transmission Control Protocol), the connection of the data synchronization protocol of the present application is established on the basis of the TCP protocol. Therefore, there is no need for the first node and the second node to go through operations such as a three-way handshake connection. The first node only needs to send the data synchronization protocol directly to the second node. After the second node receives the data synchronization protocol, it can start sending the corresponding synchronization data fragments according to the logic of the data synchronization protocol.
[0117] Optionally, the step of “configuring a data synchronization protocol according to the node information” includes:
[0118] Acquire a connectable second node according to the node information;
[0119] Obtain a shard index corresponding to the connectable second node, wherein the shard index is an index value of the synchronization data shard;
[0120] The data synchronization protocol is generated by taking the block height of the first node, the number of the second nodes to be connected, and the shard index corresponding to the connectable second nodes as protocol content.
[0121] In some embodiments, the first node may determine the content of the data synchronization protocol based on the received node information. Figure 3d As shown, the first node can cache the second node list through the node manager, and the second node list includes the second nodes that can perform data synchronization. It can be understood that after a period of time, the first node will receive the node information of all the second nodes that can be synchronized in the blockchain network, so that the first node can use all or part of the second nodes in the second node list as objects for requesting data synchronization.
[0122] In some embodiments, the data synchronization protocol may include the block height of the first node, the number of second nodes to be connected, and the shard index corresponding to the connectable second node. The shard index is the index value of the synchronization data shard, for example, a shard index of 1 corresponds to the first synchronization data shard, and a shard index of 2 corresponds to the second synchronization data shard. In some embodiments, the first node may assign a corresponding shard index to the second node based on the node information of the second node, such as the ID and IP address.
[0123] like Figure 3cAs shown, index can be used to represent the shard index, nodes can represent the number of second nodes to be connected, and height can represent the block height of the first node. After multiple second nodes receive the data synchronization request sent by the first node, they can process the synchronization data into the corresponding number of synchronization data shards according to the content of the data synchronization protocol, the number of second nodes participating in this data synchronization operation, and the block height of the first node, and subsequently send the synchronization data shards corresponding to their own shard indexes to the first node.
[0124] From this, it can be seen that after the connection is established between the first node and the second node, the first node does not need to send information such as the block height and block number of the synchronization data to the second node. All second nodes can push synchronization data shards to the first node continuously according to the content and logic of the data synchronization protocol carried by the synchronization request data when the connection is established, thereby reducing the number of times the first node sends data synchronization requests to the second node, thereby improving the efficiency of the entire data synchronization process.
[0125] Step 102: Receive the synchronized data fragments returned by each of the second nodes according to the data synchronization request, and the reputation value of each of the second nodes.
[0126] Among them, the reputation value can characterize the stable state of the second node returning the synchronized data. The reputation value can characterize the efficiency, accuracy and stability of the second node in transmitting synchronized data in the data synchronization process. The higher the reputation value, the higher the data synchronization efficiency, accuracy and stability of the second node. It can be understood that when the reputation value of a second node is continuously low, it means that there is a certain degree of abnormality in the second node, and it can be determined as an abnormal node and deleted from the second node list. Correspondingly, if the subsequent reputation value of the second node recovers and continues to a higher level, the second node can be re-added to the second node list. For example, a second node is determined to be an abnormal node due to a long offline time.
[0127] In order to ensure the efficiency of data synchronization, in some embodiments, the first node may receive synchronization data fragments divided into multiple groups. For example, if the synchronization data includes 100 blocks, the synchronization data of the 100 blocks may be equally divided into 10 groups of 10 blocks each, and then the 10 blocks in each group may be split into multiple synchronization data fragments, and each group of synchronization data is also called segmented data of the synchronization data.
[0128] Please refer to the figure Figure 3a and Figure 3b , is a schematic diagram of splicing synchronous data slices to obtain synchronous data provided by an embodiment of the present application, Figure 3b Schematic diagram of the structure of synchronization data fragmentation and each group of synchronization data provided by the embodiment of the present application. Figure 3b As shown in FIG. 1 , each synchronous data segment includes a data header and a data body. The data header is used to mark the group to which the synchronous data segment belongs. The length of the data header is fixed to 4 bytes. The content of the data body is the actual content of the synchronous data. Figure 3b Taking the three synchronous data shards in as an example, assuming that the length of the synchronous data is 600 bytes, the length of each synchronous data shard can be 200 bytes, for example, the data body of synchronous data shard 1 is 0-200 bytes, the data body of synchronous data shard 1 is 201-400 bytes, and the data body of synchronous data shard 1 is 401-600 bytes.
[0129] like Figure 3a As shown, it can be understood that after receiving the data synchronization request, the second node can retrieve the corresponding synchronization data shard according to the corresponding shard index, and then assemble the synchronization data shard as the data body with the corresponding data header, and then return the entire synchronization data shard to the first node.
[0130] Step 103: Update the data synchronization request and the second node for processing the updated data synchronization request according to the reputation value of each second node.
[0131] In some embodiments, the node manager of the first node can collect information such as the current block height, reputation value, and node status of the second node. When the node manager receives the heartbeat signal of the second node for the first time, the heartbeat signal carries the reputation value of the second node, the status of the second node defaults to normal, and the reputation value is also set to a default value, for example, the default value may be the highest reputation value. In the subsequent transmission process, if an abnormality in synchronization data sharding occurs, the reputation value of the second node will be deducted. When the reputation value is lower than a certain threshold, for example, lower than 0, the status of the second node will be set to abnormal, so only the second node with a normal status can connect to the first node, so the first node can update the data synchronization request and the subsequent connected second node according to the reputation value of the second node.
[0132] Optionally, step 103 may further include:
[0133] Calculate the reputation value of each second node according to the received synchronization data fragment or the state of each second node when sending data;
[0134] According to the reputation value of each second node, updating the locally stored second node list to obtain an updated second node list, wherein the second node list includes second nodes that can perform data synchronization;
[0135] The data synchronization request is modified according to the updated second node list.
[0136] like Figure 3d As shown, the first node can maintain the second node list through the node manager. It can be understood that since the data synchronization protocol is formulated based on the node information of the second node in the second node list, the first node can modify the data synchronization protocol accordingly according to the change of the node information of the second node list.
[0137] Optionally, the step of “calculating the reputation value of each second node according to the received synchronous data slice or the state of each second node when sending data” includes:
[0138] Obtaining the accuracy corresponding to the received synchronization data slice;
[0139] Acquire abnormal behavior of each second node when sending data;
[0140] Based on the accuracy or the abnormal behavior, the current reputation value of each second node is periodically adjusted to obtain the reputation value of each second node.
[0141] When each second node establishes a heartbeat connection with the first node for the first time, the second node's default reputation value may be the upper limit of the reputation value. Whenever the second node sends an erroneous synchronous data fragment or has abnormal behavior, its own reputation value will be deducted. For example, 1 point of the current reputation value will be deducted each time a data transmission error or abnormal behavior occurs. In some embodiments, abnormal behavior may include the second node's network transmission speed being too slow, network interruption, insufficient resources, data tampering, version incompatibility, or security vulnerabilities.
[0142] Optionally, “updating the locally stored second node list according to the reputation value of each second node” includes:
[0143] Get the abnormal threshold of reputation value;
[0144] When the reputation value of any second node in the second node list is less than the abnormal threshold, the second node is determined as a pending abnormal node;
[0145] Obtaining a first observation time duration during which the reputation value of the pending abnormal node is continuously less than the abnormal threshold;
[0146] If the first observation duration is greater than a duration threshold, the pending abnormal node is determined as an abnormal node, and the abnormal node is deleted from the second node list.
[0147] See also Figure 3e and Figure 3f , Figure 3e is a schematic diagram of determining normal nodes and abnormal nodes provided in an embodiment of the present application, Figure 3f It is a schematic diagram of modifying the data synchronization protocol provided in an embodiment of the present application.
[0148] The abnormal threshold can be set according to the needs. Assuming that the upper limit of the credibility value is 10, the abnormal threshold can be set to 0. That is, when the credibility value of a second node is deducted to a value less than 0, an event can be triggered to determine the second node as a pending abnormal node. When the first observation time that the credibility value of the pending abnormal node is continuously less than 0 is greater than the time threshold, the pending abnormal node is determined as an abnormal node and removed from the second node list.
[0149] Optionally, after the step of “obtaining a first observation time period during which the reputation value of the to-be-determined abnormal node is continuously less than the abnormal threshold”, the method further includes:
[0150] If the first observation time is less than the time threshold, and the reputation value of the pending abnormal node is restored to be greater than the abnormal threshold, the pending abnormal node is determined as a pending normal node;
[0151] Obtaining a second observation time duration during which the reputation value of the pending normal node is continuously greater than the abnormal threshold;
[0152] If the second observation time is greater than the time threshold, the pending normal node is determined as a normal node, and the normal node is retained in the second node list.
[0153] Accordingly, when the first observation duration is less than the duration threshold, and the reputation value of the pending abnormal node is restored to be greater than the abnormal threshold, an event is triggered to determine the second node as a pending normal node, such as the second node that was offline due to a network interruption is restored online and stably sends synchronization data fragments, or the second node that originally sent an erroneous synchronization data fragment sends the correct synchronization data fragment to the first node. Accordingly, when the second observation duration in which the reputation value of the pending normal node is continuously greater than 0 is greater than the duration threshold, the pending normal node is determined as a normal node and retained in the second node list.
[0154] It can be understood that in order to avoid network fluctuations caused by frequent changes in the second node list and the data synchronization protocol, a recovery period with a time threshold can be set for each pending abnormal node. During the recovery period, if the reputation value of the pending abnormal node is restored to be greater than the abnormal threshold, or the reputation value of the pending abnormal node is continuously less than the abnormal threshold, the identity of the pending abnormal node is changed, for example, the pending abnormal node is changed to a normal node or an abnormal node. It should be noted that the time threshold can be set according to demand, or it can be set according to the time when the second node has abnormal behavior again or multiple times, and this embodiment does not limit this.
[0155] Optionally, the step of “modifying the data synchronization request according to the updated second node list” includes:
[0156] Obtaining the second nodes that are added or deleted in the updated second node list compared to the second node list;
[0157] According to the node information of the newly added or deleted second node, the node information carried in the data synchronization request is modified, wherein the node information includes the name, quantity, shard index and block height of the node, and the shard index is the index value of the synchronized data shard.
[0158] It can be understood that the block height of the first node, the number of second nodes, and the shard index of each second node in the data synchronization protocol are all obtained based on the node information of the second node in the second node list. Therefore, when an exception occurs in a second node in the data synchronization process and the sending operation of the synchronized data shard cannot continue, a new data synchronization request can be generated by changing the data synchronization protocol to ensure the accuracy and stability of the data synchronization process.
[0159] Step 104: Receive updated synchronization data fragments returned by each of the updated second nodes according to the updated data synchronization request.
[0160] It can be understood that during the data synchronization process, each second node will perform data synchronization operations on the first node based on the existing and running data synchronization protocol. The data synchronization protocol includes information such as the starting block height to be synchronized, the number of second nodes, and the corresponding shard index.
[0161] Correspondingly, if the heartbeat information of a new second node is received at this time and meets the conditions for joining data synchronization, the data synchronization request will be updated based on the newly added second node, and the updated data synchronization request will be sent to all updated second nodes. All updated second nodes will receive this updated data synchronization request at the same time and start to execute the data synchronization protocol corresponding to the updated data synchronization request. Therefore, through the above method, the first node can receive the updated synchronization data fragments returned by each updated second node according to the updated data synchronization request.
[0162] Step 105: Assemble the synchronization data fragments to obtain complete synchronization data.
[0163] In some embodiments, after the first node receives all synchronized data fragments from the same group, the first node may reassemble the multiple synchronized data fragments.
[0164] Specifically, the first node can identify the group to which the current synchronization data fragment belongs through the 4 bytes of the header of each synchronization data fragment, and then splice the contents after removing the data header into a complete data in the order of the synchronization data fragments. Among them, the order of the synchronization data fragments can be determined according to the corresponding fragment index. For example, synchronization data fragment 1 and synchronization data fragment 2 can be assembled first, and then synchronization data fragment 3 can be assembled to obtain the complete synchronization data of the group.
[0165] like Figure 3f As shown, taking the newly added second node D as an example, the number of second nodes participating in this data synchronization operation changes from 3 to 4. Correspondingly, the number of synchronized data shards, the shard index of each second node, and the height of the first node will also change. Therefore, the index value, nodes value, and height value in the original data synchronization protocol can be modified according to the changed values of the above data to obtain a new data synchronization protocol and a new data synchronization request.
[0166] Step 106: Write the synchronization data into the blockchain network to synchronize the data of the second node to the first node.
[0167] In some embodiments, the first node can write the synchronization data assembled in the order of the block height in the segment into the blockchain network, and add the block of synchronization data as a new block to the end of the blockchain network. This can ensure the reliability and consistency of the data of each node in the blockchain network, and can also ensure the continuity and correctness of the blockchain.
[0168] It can be seen from this that, by applying the embodiments of the present application, the first node requesting data synchronization can send data synchronization requests to multiple second nodes participating in the consensus mechanism, and obtain complete synchronized data based on the splicing of multiple synchronized data fragments returned by the multiple second nodes.
[0169] In the above manner, the first node sends a data synchronization request to multiple second nodes. When each second node returns its own synchronization data fragment, it also returns a corresponding reputation value, so that the first node can judge the stability of the data returned by each second node based on the reputation value, and by updating the data synchronization request and the second node with high reputation, it can avoid the situation where the entire data synchronization process is terminated or cannot be carried out due to anomalies in the second node, thereby improving the stability of the data synchronization process. And by each second node returning the corresponding synchronization data fragment to the first node, until the first node obtains complete synchronization data based on all synchronization data fragments, it can reduce the network communication consumption of multiple data synchronization requests, improve the speed of transmission and acquisition of synchronization data, and thus effectively improve the efficiency of the data synchronization process.
[0170] See also Figure 2b In this embodiment, a blockchain data processing method is provided, which is executed by a first node in a blockchain network, such as Figure 2b As shown, the specific process of the data processing method of the blockchain can be as follows:
[0171] Step 201: Receive a data synchronization request sent by a first node of the blockchain network, and determine synchronization data to be sent to the first node.
[0172] In some embodiments, the second node can obtain the data synchronization protocol through a data synchronization request. According to the description of step 101, the content of the data synchronization protocol includes the block height of the first node, so the second node can determine the synchronization data that the first node needs to synchronize based on its own block height. For example, if the current block height of the first node is 9 and the current block height of the second node is 20, the block corresponding to the synchronization data is the data from block 10 to block 20.
[0173] Through the above method, the first node does not need to send information such as the height and number of blocks that need to be synchronized to the second node. The second node can accurately calculate the synchronization data directly based on the data synchronization request, thereby reducing the number and content of synchronization requests sent by the first node to the second node.
[0174] Step 202: According to the data synchronization request, the synchronization data is fragmented to obtain a plurality of synchronization data fragments.
[0175] The data synchronization request may carry a data synchronization protocol, which may include the number of second nodes participating in data synchronization and the protocol content of the block height of the first node. For a description of the data synchronization protocol, please refer to the content of the aforementioned step 101.
[0176] Optionally, step 202 may include:
[0177] Grouping the synchronization data, wherein each group of synchronization data includes data of at least one block;
[0178] Taking the number of the second nodes as the number of shards, sharding each group of synchronization data to obtain a data body of multiple shards;
[0179] Obtaining a data header with information about the group in which the data body is located;
[0180] The multiple data bodies are concatenated with corresponding data headers to obtain the multiple synchronous data fragments.
[0181] It can be understood that the nodes value in the data synchronization protocol represents the number of second nodes participating in data synchronization, so the number of each group of synchronized data shards can be determined according to the nodes value, for example Figure 3a and Figure 3b There are 3 second nodes to send 3 synchronous data fragments of the same group.
[0182] In some embodiments, before sending the synchronization data fragments, each second node performs fragmentation processing on the synchronization data to obtain multiple data bodies, such as Figure 3a Each second node will obtain the data body of synchronization data slice a, synchronization data slice b and synchronization data slice c. Then, according to the slice index assigned in the data synchronization protocol, determine which specific synchronization data slice is responsible for sending to the first node, and then splice the corresponding responsible data body with the data header to obtain the corresponding synchronization data slice to be sent. For the description of the data header, data body and slice index, please refer to the content of the aforementioned step 102.
[0183] Step 203: Determine a synchronization data segment to be sent from the multiple synchronization data segments.
[0184] According to the description of step 101, the second node can determine the synchronous data shard to be sent according to the allocated shard index, for example Figure 3a In the example, the second node A is responsible for sending the same data slice a, the second node B is responsible for sending the same data slice b, and the second node C is responsible for sending the same data slice c.
[0185] Thus, the synchronization data fragments of the synchronization data are sent to the first node through multiple second nodes. The synchronization data fragments are part of the synchronization data, so the memory occupancy is smaller, which can significantly improve the efficiency of data synchronization for the first node.
[0186] Step 204: continuously send the synchronization data shard and the corresponding reputation value to the first node, so that the first node obtains complete synchronization data based on the synchronization data shard or the updated synchronization data shard obtained based on the reputation value, wherein the reputation value represents the stable state of the synchronization data returned by the second node.
[0187] The synchronization data may be divided into a target number of transmission rounds and sent. In some embodiments, the number of transmission rounds may be equal to the number of groups of the synchronization data.
[0188] Optionally, step 204 may include:
[0189] In the current sending round, the synchronous data slices belonging to the current sending round are sent to the first node to complete the data sending operation of the current sending round;
[0190] In the remaining sending rounds, the data sending operation is repeatedly performed until the data sending operations of the target number of sending rounds are completed.
[0191] According to the description of the aforementioned step 103, when the first node receives all the synchronization data fragments from the same group, it can reassemble the above multiple synchronization data fragments to assemble the synchronization data of the group. That is, all the second nodes participating in data synchronization accurately send their own synchronization data fragments to the first node, then the current sending round ends, and the second node will continue to send each group of data synchronization fragments to the first node until the first node obtains the synchronization data fragments of all groups and splices them to obtain complete synchronization data.
[0192] It should be noted that for less synchronization data, for example, the first node only requests to synchronize the synchronization data of one block, the synchronization data may not be grouped, or it can be understood that there is only one group for the synchronization data. Therefore, this embodiment does not limit the number of groups for the same data.
[0193] It can be seen from this that, by applying the embodiments of the present application, the first node requesting data synchronization can send data synchronization requests to multiple second nodes participating in the consensus mechanism, and obtain complete synchronized data based on the splicing of multiple synchronized data fragments returned by the multiple second nodes.
[0194] In the above manner, the first node sends a data synchronization request to multiple second nodes. When each second node returns its own synchronization data fragment, it also returns a corresponding reputation value, so that the first node can judge the stability of the data returned by each second node based on the reputation value, and by updating the data synchronization request and the second node with high reputation, it can avoid the situation where the entire data synchronization process is terminated or cannot be carried out due to anomalies in the second node, thereby improving the stability of the data synchronization process. And by each second node returning the corresponding synchronization data fragment to the first node, until the first node obtains complete synchronization data based on all synchronization data fragments, it can reduce the network communication consumption of multiple data synchronization requests, improve the speed of transmission and acquisition of synchronization data, and thus effectively improve the efficiency of the data synchronization process.
[0195] Among them, another specific process of the data processing method of the above blockchain is as follows, refer to Figure 2c , the method further comprises the following steps:
[0196] Step 301: receiving node information sent by multiple second nodes;
[0197] Step 302: configure a data synchronization protocol according to the node information;
[0198] Step 303: Add the data synchronization protocol to the request message of the first node to generate a data synchronization request;
[0199] Step 304: Send a data synchronization request to multiple second nodes of the blockchain network;
[0200] Step 305: Receive the synchronization data fragments and reputation values returned by each second node according to the data synchronization request;
[0201] Step 306: updating the data synchronization request and the second node for processing the updated data synchronization request according to the reputation value of each second node;
[0202] Step 307: receiving updated synchronization data fragments returned by each updated second node according to the updated data synchronization request;
[0203] Step 308: Assemble the updated synchronization data fragments to obtain complete synchronization data;
[0204] Step 309: Write the synchronization data into the blockchain network to synchronize the data of the second node to the first node.
[0205] Among them, another specific process of the data processing method of the above blockchain is as follows, refer to Figure 2d , the method further comprises the following steps:
[0206] Step 401: receiving a data synchronization request sent by a first node of the blockchain network, and determining synchronization data to be sent to the first node;
[0207] Step 402: grouping the synchronization data, wherein each group of synchronization data includes data of at least one block;
[0208] Step 403: Taking the number of second nodes as the number of shards, shard each set of synchronization data to obtain a data body of multiple shards;
[0209] Step 404, obtaining a data header with information about the group where the data body is located;
[0210] Step 405: concatenate multiple data bodies with corresponding data headers to obtain multiple synchronous data fragments;
[0211] Step 406: Determine a synchronization data segment to be sent from multiple synchronization data segments;
[0212] Step 407: In the current sending round, the synchronization data fragments belonging to the current sending round are sent to the first node to complete the data sending operation of the current sending round;
[0213] Step 408: Repeat the data sending operation in the remaining sending rounds until the data sending operation of the target number of sending rounds is completed.
[0214] It is understandable that in the specific implementation of the present application, related data such as blockchain network data, user information, and transaction data stored in blocks are involved. When the above embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data need to comply with the relevant laws, regulations and standards of the relevant countries and maps. For example, the collection of new task data and the collection of old task data involved in this application are all collected with the permission of the user and in compliance with relevant laws, regulations and standards; illustratively, when collecting data, the subsequent data collection is introduced in the form of a pop-up window in the user interface, and then when the user's confirmation operation on the pop-up window is detected, it is determined that the user agrees to collect data, and then the data collection process is started.
[0215] The method described in the above embodiment will be further described in detail below.
[0216] like Figure 4a , which is a schematic diagram of the structure of a blockchain data processing device provided in an embodiment of the present application, and the device is applied to a first node, including:
[0217] A request sending unit 501 is used to send a data synchronization request to multiple second nodes of the blockchain network;
[0218] A shard receiving unit 502 is configured to receive the synchronized data shards returned by each second node according to the data synchronization request, and the reputation value of each second node, wherein the reputation value represents the stable state of the synchronized data returned by the second node;
[0219] A data updating unit 503, configured to update the data synchronization request according to the reputation value of each second node, and a second node configured to process the updated data synchronization request;
[0220] An updated data receiving unit 504 is used to receive updated synchronization data fragments returned by each of the updated second nodes according to the updated data synchronization request;
[0221] A fragment assembly unit 505, used to assemble the synchronization data fragments to obtain complete synchronization data;
[0222] The data writing unit 506 is used to write the synchronization data into the blockchain network to synchronize the data of the second node to the first node.
[0223] Optionally, the blockchain data processing device further includes:
[0224] A node information receiving unit, configured to receive node information sent by a plurality of second nodes, wherein the node information includes a name and a block height of a corresponding second node;
[0225] A data synchronization protocol configuration unit, configured to configure a data synchronization protocol according to the node information, wherein the data synchronization protocol is used to define a second node that performs a data synchronization operation for the first node, and an execution logic of the data synchronization operation;
[0226] A protocol generating unit is used to add the data synchronization protocol to the request message of the first node to generate the data synchronization request.
[0227] Optionally, the data synchronization protocol configuration unit is further specifically used for:
[0228] Acquire a connectable second node according to the node information;
[0229] Obtain a shard index corresponding to the connectable second node, wherein the shard index is an index value of the synchronization data shard;
[0230] The data synchronization protocol is generated by taking the block height of the first node, the number of the second nodes to be connected, and the shard index corresponding to the connectable second nodes as protocol content.
[0231] Optionally, the data updating unit includes:
[0232] A reputation value calculation subunit, configured to calculate the reputation value of each second node according to the received synchronization data fragments or the state of each second node when sending data;
[0233] A list updating subunit, configured to update a locally stored second node list according to the reputation value of each second node, to obtain an updated second node list, wherein the second node list includes second nodes capable of data synchronization;
[0234] The request modification subunit is used to modify the data synchronization request according to the updated second node list.
[0235] Optionally, the reputation value calculation subunit is further specifically used for:
[0236] Obtaining the accuracy corresponding to the received synchronization data slice;
[0237] Acquire abnormal behavior of each second node when sending data;
[0238] Based on the accuracy or the abnormal behavior, the current reputation value of each second node is periodically adjusted to obtain the reputation value of each second node.
[0239] Optionally, the list updating unit is further specifically configured to:
[0240] Get the abnormal threshold of reputation value;
[0241] When the reputation value of any second node in the second node list is less than the abnormal threshold, the second node is determined as a pending abnormal node;
[0242] Obtaining a first observation time duration during which the reputation value of the pending abnormal node is continuously less than the abnormal threshold;
[0243] If the first observation duration is greater than a duration threshold, the pending abnormal node is determined as an abnormal node, and the abnormal node is deleted from the second node list.
[0244] Optionally, the blockchain data processing device further includes:
[0245] a pending abnormal node determining unit, configured to determine the pending abnormal node as a pending normal node if the first observation duration is less than a duration threshold and the reputation value of the pending abnormal node is restored to be greater than the abnormal threshold;
[0246] A second observation duration acquisition unit, used to acquire a second observation duration during which the reputation value of the pending normal node is continuously greater than the abnormal threshold;
[0247] A normal node determination unit is configured to determine the pending normal node as a normal node and retain the normal node in the second node list if the second observation duration is greater than the duration threshold.
[0248] Optionally, the request modification subunit is further specifically used for:
[0249] Obtaining the second nodes that are added or deleted in the updated second node list compared to the second node list;
[0250] According to the node information of the newly added or deleted second node, the node information carried in the data synchronization request is modified, wherein the node information includes the name, quantity, shard index and block height of the node, and the shard index is the index value of the synchronized data shard.
[0251] like Figure 4b , which is a schematic diagram of the structure of a blockchain data processing device provided in an embodiment of the present application, and the device is applied to a second node, including:
[0252] A request receiving unit 601 is used to receive a data synchronization request sent by a first node of the blockchain network, and determine synchronization data to be sent to the first node;
[0253] A shard processing unit 602 is used to perform shard processing on the synchronization data according to the data synchronization request to obtain multiple synchronization data shards;
[0254] A fragment screening unit 603, configured to determine a synchronization data fragment to be sent from the multiple synchronization data fragments;
[0255] The fragment sending unit 604 is used to continuously send the synchronization data fragment and the corresponding reputation value to the first node, so that the first node obtains complete synchronization data based on the synchronization data fragment, or based on the updated synchronization data fragment obtained based on the reputation value, wherein the reputation value represents the stable state of the synchronization data returned by the second node.
[0256] Optionally, the data synchronization request carries a data synchronization protocol, wherein the data synchronization protocol includes the number of second nodes participating in data synchronization and protocol content of the block height of the first node;
[0257] The shard processing unit is further specifically used for:
[0258] Grouping the synchronization data, wherein each group of synchronization data includes data of at least one block;
[0259] Taking the number of the second nodes as the number of shards, sharding each group of synchronization data to obtain a data body of multiple shards;
[0260] Obtaining a data header with information about the group in which the data body is located;
[0261] The multiple data bodies are concatenated with corresponding data headers to obtain the multiple synchronous data fragments.
[0262] Optionally, the synchronization data is sent in a target number of sending rounds;
[0263] The fragment sending unit is further specifically used for:
[0264] In the current sending round, the synchronous data slices belonging to the current sending round are sent to the first node to complete the data sending operation of the current sending round;
[0265] In the remaining sending rounds, the data sending operation is repeatedly performed until the data sending operations of the target number of sending rounds are completed.
[0266] It can be seen from this that, by applying the embodiments of the present application, the first node requesting data synchronization can send data synchronization requests to multiple second nodes participating in the consensus mechanism, and obtain complete synchronized data based on the splicing of multiple synchronized data fragments returned by the multiple second nodes.
[0267] In the above manner, the first node sends a data synchronization request to multiple second nodes. When each second node returns its own synchronization data fragment, it also returns a corresponding reputation value, so that the first node can judge the stability of the data returned by each second node based on the reputation value, and by updating the data synchronization request and the second node with high reputation, it can avoid the situation where the entire data synchronization process is terminated or cannot be carried out due to anomalies in the second node, thereby improving the stability of the data synchronization process. And by each second node returning the corresponding synchronization data fragment to the first node, until the first node obtains complete synchronization data based on all synchronization data fragments, it can reduce the network communication consumption of multiple data synchronization requests, improve the speed of transmission and acquisition of synchronization data, and thus effectively improve the efficiency of the data synchronization process.
[0268] The present application also provides an electronic device, which may be a terminal, a server, or other device. Figure 5 As shown, it shows a schematic diagram of the structure of the electronic device involved in the embodiment of the present application, specifically:
[0269] The electronic device may include one or more processors 701 of processing cores, one or more memory 702 of readable storage media, a power supply 703, an input unit 704, and a communication unit 705. Those skilled in the art will appreciate that Figure 5 The electronic device structure shown in the figure does not limit the electronic device, and may include more or less components than shown in the figure, or combine some components, or arrange the components differently.
[0270] The processor 701 is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire electronic device. It executes various functions of the electronic device and processes data by running or executing software programs and / or units stored in the memory 702, and calling data stored in the memory 702. In some embodiments, the processor 701 may include one or more processing cores; in some embodiments, the processor 701 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 701.
[0271] The memory 702 can be used to store software programs and units. The processor 701 executes various functional applications and data processing by running the software programs and units stored in the memory 702. The memory 702 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 702 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 702 may also include a memory controller to provide the processor 701 with access to the memory 702.
[0272] The electronic device also includes a power supply 703 for supplying power to various components. In some embodiments, the power supply 703 can be logically connected to the processor 701 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 703 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.
[0273] The electronic device may further include an input unit 704, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0274] The electronic device may further include a communication unit 705. In some embodiments, the communication unit 705 may include a wireless unit. The electronic device may perform short-range wireless transmission through the wireless unit of the communication unit 705, thereby providing the user with wireless broadband Internet access. For example, the communication unit 705 may be used to help the user send and receive emails, browse web pages, and access streaming media.
[0275] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 701 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 702 according to the following instructions, and the processor 701 will run the application programs stored in the memory 702, thereby realizing various functions, as follows:
[0276] Initiating a location verification request to the invited terminal, so that the invited terminal returns location verification information according to the location verification request;
[0277] The location verification information of the invited end is verified. When the location verification information of the invited end and the location verification information of the inviting end pass the location consistency verification, the registration request of the inviting end is successful.
[0278] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0279] From the above, it can be seen that, by applying the embodiments of the present application, the first node requesting data synchronization can send data synchronization requests to multiple second nodes participating in the consensus mechanism, and obtain complete synchronized data based on the splicing of multiple synchronized data fragments returned by the multiple second nodes.
[0280] In the above manner, the first node sends a data synchronization request to multiple second nodes. When each second node returns its own synchronization data fragment, it also returns a corresponding reputation value, so that the first node can judge the stability of the data returned by each second node based on the reputation value, and by updating the data synchronization request and the second node with high reputation, it can avoid the situation where the entire data synchronization process is terminated or cannot be carried out due to anomalies in the second node, thereby improving the stability of the data synchronization process. And by each second node returning the corresponding synchronization data fragment to the first node, until the first node obtains complete synchronization data based on all synchronization data fragments, it can reduce the network communication consumption of multiple data synchronization requests, improve the speed of transmission and acquisition of synchronization data, and thus effectively improve the efficiency of the data synchronization process.
[0281] To this end, the embodiment of the present application provides a readable storage medium, which stores multiple instructions, which can be loaded by a processor to execute the steps in any blockchain data processing method provided in the embodiment of the present application. For example, the instruction can execute the following steps:
[0282] Initiating a location verification request to the invited terminal, so that the invited terminal returns location verification information according to the location verification request;
[0283] The location verification information of the invited end is verified. When the location verification information of the invited end and the location verification information of the inviting end pass the location consistency verification, the registration request of the inviting end is successful.
[0284] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0285] Since the instructions stored in the storage medium can execute the steps in any blockchain data processing method provided in the embodiments of the present application, the beneficial effects that can be achieved by any blockchain data processing method provided in the embodiments of the present application can be achieved. For details, please refer to the previous embodiments and will not be repeated here.
[0286] The above is a detailed introduction to a blockchain data processing method, device, system, electronic device and readable storage medium provided in the embodiments of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A data processing method for blockchain, It is characterized in that The method is performed by a first node of a blockchain network, and includes: Sending a data synchronization request to multiple second nodes of the blockchain network; Receiving the synchronized data shards returned by each second node according to the data synchronization request, and the reputation value of each second node, wherein the reputation value represents the stable state of the synchronized data returned by the second node, and the reputation value of each second node, wherein the reputation value represents the stable state of the synchronized data returned by the second node; updating the data synchronization request and the second node for processing the updated data synchronization request according to the reputation value of each second node; Receiving the updated synchronization data fragment returned by each of the updated second nodes according to the updated data synchronization request; Assembling the updated synchronization data fragments to obtain complete synchronization data; The synchronization data is written into the blockchain network to synchronize the data of the second node to the first node.
2. The method according to claim 1, It is characterized in that Before sending the data synchronization request to the second node of the blockchain network, the method further includes: Receiving node information sent by multiple second nodes, wherein the node information includes a name and a block height of the corresponding second node; According to the node information, configure a data synchronization protocol, wherein the data synchronization protocol is used to define a second node that performs a data synchronization operation for the first node, and an execution logic of the data synchronization operation; The data synchronization protocol is added to the request message of the first node to generate the data synchronization request.
3. The method according to claim 2, It is characterized in that The configuring a data synchronization protocol according to the node information includes: Acquire a connectable second node according to the node information; Obtain a shard index corresponding to the connectable second node, wherein the shard index is an index value of the synchronization data shard; The data synchronization protocol is generated by taking the block height of the first node, the number of the second nodes to be connected, and the shard index corresponding to the connectable second nodes as protocol content.
4. The method according to claim 1, It is characterized in that The updating of the data synchronization request according to the reputation value of each second node, and the second node for processing the updated data synchronization request, include: Calculate the reputation value of each second node according to the received synchronization data fragment or the state of each second node when sending data; According to the reputation value of each second node, updating the locally stored second node list to obtain an updated second node list, wherein the second node list includes second nodes that can perform data synchronization; The data synchronization request is modified according to the updated second node list.
5. The method according to claim 4, It is characterized in that The calculating the reputation value of each second node according to the received synchronous data fragment or the state of each second node when sending data includes: Obtaining the accuracy corresponding to the received synchronization data slice; Acquire abnormal behavior of each second node when sending data; Based on the accuracy or the abnormal behavior, the current reputation value of each second node is periodically adjusted to obtain the reputation value of each second node.
6. The method according to claim 5, It is characterized in that The updating of the locally stored second node list according to the reputation value of each second node includes: Get the abnormal threshold of reputation value; When the reputation value of any second node in the second node list is less than the abnormal threshold, the second node is determined as a pending abnormal node; Obtaining a first observation time duration during which the reputation value of the pending abnormal node is continuously less than the abnormal threshold; If the first observation duration is greater than a duration threshold, the pending abnormal node is determined as an abnormal node, and the abnormal node is deleted from the second node list.
7. The method according to claim 5, It is characterized in that After obtaining the reputation value of the pending abnormal node and continuously obtaining the reputation value of the pending abnormal node less than the abnormal threshold value for a first observation period, the method further includes: If the first observation time is less than the time threshold, and the reputation value of the pending abnormal node is restored to be greater than the abnormal threshold, the pending abnormal node is determined as a pending normal node; Obtaining a second observation time duration during which the reputation value of the pending normal node is continuously greater than the abnormal threshold; If the second observation time is greater than the time threshold, the pending normal node is determined as a normal node, and the normal node is retained in the second node list.
8. The method according to any one of claims 4 to 7, It is characterized in that The step of modifying the data synchronization request according to the updated second node list includes: Obtaining the second nodes that are added or deleted in the updated second node list compared to the second node list; According to the node information of the newly added or deleted second node, the node information carried in the data synchronization request is modified, wherein the node information includes the name, quantity, shard index and block height of the node, and the shard index is the index value of the synchronized data shard.
9. A data processing method for blockchain, It is characterized in that The method is performed by a second node of the blockchain network, and the method includes: Receiving a data synchronization request sent by a first node of the blockchain network, and determining synchronization data to be sent to the first node; According to the data synchronization request, the synchronization data is fragmented to obtain a plurality of synchronization data fragments; Determine a synchronization data segment to be sent from the multiple synchronization data segments; The synchronization data shards and corresponding reputation values are continuously sent to the first node, so that the first node obtains complete synchronization data based on the synchronization data shards, or based on the updated synchronization data shards obtained based on the reputation values, wherein the reputation value represents the stable state of the synchronization data returned by the second node.
10. The method according to claim 9, It is characterized in that The data synchronization request carries a data synchronization protocol, wherein the data synchronization protocol includes the number of second nodes participating in data synchronization and the protocol content of the block height of the first node; The slicing of the synchronization data according to the data synchronization request to obtain a plurality of synchronization data slicings includes: Grouping the synchronization data, wherein each group of synchronization data includes data of at least one block; Taking the number of the second nodes as the number of shards, sharding each group of synchronization data to obtain a data body of multiple shards; Obtaining a data header with information about the group in which the data body is located; The multiple data bodies are concatenated with corresponding data headers to obtain the multiple synchronous data fragments.
11. The method according to claim 9, It is characterized in that The synchronization data is divided into a target number of sending rounds and sent; The continuously sending the synchronization data shards and the corresponding reputation values to the first node includes: In the current sending round, the synchronization data shards and corresponding reputation values belonging to the current sending round are sent to the first node to complete the data sending operation of the current sending round; In the remaining sending rounds, the data sending operation is repeatedly performed until the data sending operations of the target number of sending rounds are completed.
12. A data processing device for blockchain, It is characterized in that The device is applied to a first node of a blockchain network, and the device includes: A request sending unit, configured to send a data synchronization request to a plurality of second nodes of the blockchain network; A shard receiving unit, configured to receive the synchronized data shards returned by each second node according to the data synchronization request, and a reputation value of each second node, wherein the reputation value represents a stable state of the synchronized data returned by the second node; a data updating unit, configured to update the data synchronization request according to the reputation value of each second node, and a second node configured to process the updated data synchronization request; An updated data receiving unit, configured to receive updated synchronization data fragments returned by each of the updated second nodes according to the updated data synchronization request; A fragment assembly unit, used for assembling the updated synchronization data fragments to obtain complete synchronization data; A data writing unit is used to write the synchronization data into the blockchain network to synchronize the data of the second node to the first node.
13. A data processing device for blockchain, It is characterized in that The device is applied to a second node of a blockchain network, and the device includes: A request receiving unit, configured to receive a data synchronization request sent by a first node of the blockchain network, and determine synchronization data to be sent to the first node; A shard processing unit, configured to perform shard processing on the synchronization data according to the data synchronization request to obtain a plurality of synchronization data shards; A fragment screening unit, used for determining a synchronization data fragment to be sent from the multiple synchronization data fragments; A shard sending unit is used to continuously send the synchronization data shard and the corresponding reputation value to the first node, so that the first node obtains complete synchronization data based on the synchronization data shard, or based on the updated synchronization data shard obtained based on the reputation value, wherein the reputation value represents the stable state of the synchronization data returned by the second node.
14. An electronic device, It is characterized in that include: Processors and storage media; The processor is used to implement each instruction; The storage medium is used to store a plurality of instructions, and the instructions are used to be loaded by a processor and execute the blockchain data processing method according to any one of claims 1 to 11.
15. A readable storage medium storing executable instructions, It is characterized in that When the executable instructions are executed by the processor, the blockchain data processing method described in any one of claims 1 to 11 is implemented.
16. A computer program product comprising a computer program or instructions, It is characterized in that When the computer program or instruction is executed by a processor, the blockchain data processing method described in any one of claims 1 to 11 is implemented.
