Block chain data acquisition method and device, computer equipment and storage medium

By adjusting collection parameters and removing abnormal nodes in real time, it solves the problems of low data acquisition efficiency and low network stability in traditional blockchain data collection methods, and achieves fast loading of blockchain browser pages and improved data collection performance.

CN118733916APending Publication Date: 2024-10-01HANGZHOU HIGH-TECH ZONE (BINJIANG) INSTITUTE OF BLOCKCHAIN & DATA SECURITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410668585.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-27
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

Traditional blockchain data collection methods have problems such as low data acquisition efficiency, inconsistent data, and too high or low load on blockchain nodes, resulting in low blockchain data collection performance and low network stability.

Method used

By obtaining the collection parameters converted from the transmission parameters through the preset mapping relationship, the block header and block body of the block are collected based on the real-time adjusted collection parameters, abnormal nodes are removed, and the collection parameters are dynamically adjusted to avoid the node load being too high or too low. , to achieve fast acquisition of data and fast loading of browser pages.

Benefits of technology

It improves data collection efficiency, avoids instability caused by excessive load on blockchain network nodes, and achieves fast loading of blockchain browser pages and improved data collection performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118733916A_ABST
    Figure CN118733916A_ABST
Patent Text Reader

Abstract

The invention relates to a block chain data acquisition method and device, computer equipment and a storage medium. The method comprises the following steps: acquiring an acquisition parameter obtained by converting a transmission parameter through a preset mapping relationship; wherein the transmission parameter is a parameter when the data of the target data source is uploaded to a block chain network corresponding to the browser page, and the mapping relation is used for representing a relation between the transmission parameter and a maximum acquisition parameter which can be borne by the current network resource; collecting a block head of the block in the target data source according to the collection parameter, and updating meta-information data of the block in the browser page based on the block head; under the condition that collection of the block head of the block chain node is completed, the block body of the block is collected based on the collection parameters, the transaction data of the block is updated in the browser page based on the block body, and by adopting the method, the problems that in the data collection process of a block chain browser, the data collection performance is low, and the block chain network stability is low can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain, and in particular to blockchain data collection methods, devices, computer equipment and storage media. Background Art

[0002] Blockchain data collection refers to the process of collecting various types of information and transaction records from the blockchain network. The widespread application of blockchain technology has led to an increasing demand for real-time acquisition and monitoring of block data.

[0003] In the traditional blockchain data collection method, data is collected through the API (Application Programming Interface) interface provided by the target data source chain or exchange, or the data collection service provided by a third-party service, to achieve regular incremental data acquisition. The traditional blockchain data collection method does not take into account the problems of low data acquisition efficiency, inconsistent data, and excessive or low blockchain node load during the data acquisition process. These problems will not only lead to low collection performance during the blockchain data collection process, but also cause the blockchain network performance to significantly decline or crash, which in turn leads to low stability of the blockchain network.

[0004] With regard to the problems of low data collection performance and low blockchain network stability in the process of blockchain browser data collection in related technologies, no effective solution has been proposed so far. Summary of the invention

[0005] Based on this, it is necessary to provide a blockchain data collection method, device, system, electronic device and storage medium that can solve the problems of low data collection performance and low blockchain network stability in the blockchain browser data process in response to the above-mentioned technical problems.

[0006] In the first aspect, a blockchain data collection method is provided in this embodiment, and the method includes:

[0007] Obtaining acquisition parameters obtained by converting transmission parameters through a preset mapping relationship; wherein the transmission parameters are parameters when the data of the target data source is uploaded to the blockchain network corresponding to the browser page, and the mapping relationship is used to characterize the relationship between the transmission parameters and the maximum acquisition parameters that the current network resources can bear;

[0008] Collecting a block header of a block in the target data source according to the collection parameters, and updating meta information data of the block in the browser page based on the block header;

[0009] When the block header of the blockchain node is collected, the block body of the block is collected based on the collection parameters, and the transaction data of the block is updated in the browser page based on the block body.

[0010] In some embodiments, obtaining the mapping relationship includes:

[0011] constructing a feature set according to historical transmission parameters when collecting the target data source, historical network resource parameters corresponding to the historical transmission parameters, and historical collection parameters;

[0012] Training a preset model according to the feature set;

[0013] When the preset model converges, the mapping relationship is obtained according to the preset model.

[0014] In some embodiments, the step of training a preset model according to the feature set includes:

[0015] Dividing the feature set to obtain a training set and a validation set;

[0016] Training the preset model according to the training set, and evaluating the trained preset model according to the validation set to obtain an evaluation result of the preset model;

[0017] The parameters of the preset model are adjusted according to the evaluation results.

[0018] In some embodiments, collecting the block header of the block in the target data source based on the collection parameter includes:

[0019] Comparing the block range of the block to be collected in the target data source with the threshold range;

[0020] When the block range is greater than or equal to the threshold range, the block header of the block is collected in the target data source based on the collection parameters.

[0021] In some of the embodiments, before collecting the block header of the block in the target data source based on the collection parameter, the method further includes:

[0022] Obtain the connection status of each blockchain node in the target data source;

[0023] The blockchain node with abnormal connection status is removed from the target data source.

[0024] In some of the embodiments, before collecting the block header of the block in the target data source based on the collection parameter, the method further includes:

[0025] Obtaining the block hash value obtained by querying each blockchain node in the target data source;

[0026] Each blockchain node in the target data source queries the block hash value of the latest block at the same height;

[0027] If there is a target blockchain node in the target data source whose query result of the block hash value is inconsistent with the block hash value obtained by querying the majority of nodes that meet the consensus fault tolerance rules, the target blockchain node is removed from the target data source.

[0028] In some of the embodiments, after removing at least one of the blockchain nodes from the target data source, the method includes:

[0029] Anomaly detection is performed on the target data source according to preset rules, and warning information is generated according to the anomaly detection results.

[0030] In a second aspect, a blockchain data collection device is provided in this embodiment, and the device includes:

[0031] A parameter acquisition module is used to obtain the acquisition parameters obtained by converting the transmission parameters through a preset mapping relationship; wherein the transmission parameters are the parameters when the data of the target data source is uploaded to the blockchain network corresponding to the browser page, and the mapping relationship is used to characterize the relationship between the transmission parameters and the maximum acquisition parameters that the current network resources can bear;

[0032] A first collection module, configured to collect a block header of a block in the target data source according to the collection parameter, and update the meta information data of the block in the browser page based on the block header;

[0033] The second collection module is used to collect the block body of the block based on the collection parameters when the block header of the blockchain node is collected, and update the transaction data of the block in the browser page based on the block body.

[0034] In a third aspect, a computer device is provided in this embodiment, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the blockchain data collection method described in the first aspect is implemented.

[0035] In a fourth aspect, a computer-readable storage medium is provided in this embodiment, on which a computer program is stored, characterized in that when the computer program is executed by a processor, the blockchain data collection method described in the first aspect above is performed.

[0036] The above-mentioned blockchain data collection method, device, computer equipment and storage medium obtain transmission parameters, obtain the maximum collection parameters under the current network resource load according to the mapping relationship and the transmission parameters, and obtain the block header and block body of the block in succession based on the real-time adjusted collection parameters, thereby avoiding the waste of network collection resources caused by the low load of the blockchain network node, improving the data collection efficiency, and also avoiding the instability of the blockchain network caused by the high load of the blockchain network node. And the blockchain browser can first display the block overview information according to the meta information data in the block header, and then display the block transaction information according to the block body, so as to realize the rapid loading of the blockchain browser page, thereby improving the collection performance in the data collection process and the stability of the blockchain network. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 This is an application environment diagram of a blockchain data collection method in one embodiment;

[0038] Figure 2 A flowchart of a blockchain data collection method in one embodiment;

[0039] Figure 3 A flowchart of a blockchain browser adaptive collection method in one embodiment;

[0040] Figure 4 A flowchart of a blockchain data analysis method in one embodiment;

[0041] Figure 5 It is a structural block diagram of a blockchain data collection device in one embodiment;

[0042] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0043] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0044] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the", "these" and the like in this application do not represent quantitative restrictions, and they can be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether directly or indirectly. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. Usually, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0045] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1 This is a hardware structure diagram of a terminal of a blockchain data collection method according to an embodiment of the present application. Figure 1 As shown, the terminal may include one or more ( Figure 1 Only one is shown in the figure) processor 102 and memory 104 for storing data, wherein processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.

[0046] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the blockchain data collection method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0047] The transmission device 106 is used to receive or send data via a network. The above network includes a wireless network provided by the communication provider of the terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.

[0048] In this embodiment, a blockchain data collection method is provided. Figure 2 is a flow chart of the blockchain data collection method of this embodiment, such as Figure 2 As shown, the process includes the following steps:

[0049] Step S201, obtaining the collection parameters obtained by converting the transmission parameters through a preset mapping relationship; wherein the transmission parameters are the parameters when the data of the target data source is uploaded to the blockchain network corresponding to the browser page, and the mapping relationship is used to characterize the relationship between the transmission parameters and the maximum collection parameters that the current network resources can bear.

[0050] Among them, transmission parameters include but are not limited to the number of transactions processed per second when the data of the target data source is uploaded to the blockchain network corresponding to the browser page, the speed of propagation of transaction information between network nodes, data transmission rate, and other parameters used to characterize transmission efficiency. Collection parameters include but are not limited to the query rate per second of the server used to collect data, the frequency of data collection, and other parameters used to characterize collection efficiency. Network resources refer to the processing power of the processor currently performing data collection, for example, the bandwidth, latency, number of read and write operations, and other network resources that limit the efficiency of data collection.

[0051] For example, the transmission parameter is the TPS (Transactions Per Second) of blockchain transactions, and the collection parameter is the QPS (Queries per second) of each blockchain node. The mapping relationship between the TPS and the QPS is established based on the network delay affected by network resources, and the maximum QPS corresponding to the current TPS of the transaction chain is obtained when the network delay is not greater than the specified value. The transmission parameters, collection parameters, and network resource parameters can also use one or more other parameters, which will not be described here.

[0052] Optionally, the transmission parameters of the target data source in the process of uploading the data to the blockchain network corresponding to the browser page are obtained in real time, the maximum acquisition parameters corresponding to the current transmission parameters are found based on the mapping relationship, and the blockchain data is collected based on the maximum acquisition parameters obtained in real time. During the data collection process of the target data source, if the transmission parameters change, the maximum acquisition parameters corresponding to the new transmission parameters are found based on the mapping relationship to achieve dynamic acquisition and dynamic adjustment of the maximum acquisition parameters.

[0053] Step S202: collecting the block header of the block in the target data source according to the collection parameters, and updating the meta information data of the block in the browser page based on the block header.

[0054] Among them, the browser page of the blockchain is used to provide the target data source information to the user, including the meta information data and transaction information of each block. The block is the basic unit of the blockchain, and the block header is the starting part of each block, which contains the key information required to verify the validity of the block and link the blocks to form a chain structure, such as the block height, timestamp, hash value of the previous block and other data. Optionally, the meta information data is obtained by collecting the block header of the blockchain node, and the meta information data is uploaded to the blockchain network corresponding to the browser page, and the overview data of the collected block is displayed in the blockchain browser page, such as the version number of the block, timestamp, and meta information data for verifying the legitimacy of the block.

[0055] Step S203, when the block header of the blockchain node is collected, the block body of the block is collected based on the collection parameters, and the transaction data of the block is updated in the browser page based on the block body.

[0056] Among them, the block body refers to the part of a block other than the block header, which is used to store transaction data on the blockchain. Optionally, the transaction data of each block is obtained by collecting the block body of the block, and the transaction data is uploaded to the blockchain network corresponding to the browser page, and the metadata data and transaction data of the block are associated and displayed in the blockchain browser page. Optionally, the metadata data and transaction data of the block are associated and displayed, including: using the metadata data of each block as the overview information of the upper-level browser page, designing the next-level browsing page for these blocks, and automatically loading the transaction data related to the corresponding block in the upper-level browsing page when the user navigates to the next-level page.

[0057] The above steps adjust the collection parameters that the current network resources can bear according to the transmission parameters obtained in real time, and realize data collection according to the collection parameters, thereby avoiding the waste of network collection resources due to the low load of blockchain network nodes, improving the data collection efficiency, and also avoiding the instability of the blockchain network caused by the high load of blockchain network nodes. When collecting data based on the collection parameters, the block header and the block body are collected successively, and the display of different information on the browser page is realized according to the block header and the block body respectively. Since the amount of data in the block header is usually smaller than the amount of data in the block body, collecting the block header first can reduce the amount of data when the browser page is first loaded, speeding up the page presentation, and at the same time, the node load can be reduced by gradually loading, thereby improving the collection performance and blockchain network stability during the data collection process, and solving the problems of low collection performance and low stability of the blockchain network during the data collection process.

[0058] In some of the embodiments, obtaining a mapping relationship includes: constructing a feature set based on historical transmission parameters when collecting a target data source, historical network resource parameters corresponding to the historical transmission parameters, and historical collection parameters; training a preset model based on the feature set; and obtaining a mapping relationship based on the preset model when the preset model converges.

[0059] Among them, historical transmission parameters include but are not limited to: the number of transactions processed per second when the data of the target data source is uploaded to the blockchain network corresponding to the browser page in the historical time, the propagation speed of transaction information between network nodes, data transmission rate and other parameters. Historical network resource parameters include but are not limited to: network topology structure, node network configuration, network delay and other parameters in the historical time. Historical collection parameters include but are not limited to: the query rate per second of the server used to collect data in the historical time, data collection frequency and other parameters used to characterize the collection efficiency.

[0060] The preset model is a machine learning model. Optionally, after collecting the historical transmission parameters, the historical network resource parameters corresponding to the historical transmission parameters, and the historical collection parameters, the data is preprocessed by removing outliers and standardizing. The features required for the training model are selected from the preprocessed parameters to construct a feature set, so that according to the parameters in the feature set, the historical performance of each blockchain node of the target data source, the network topology, the node hardware configuration and other performance related to data collection can be reflected. For example, the historical transmission parameter selects the blockchain transaction on-chain TPS, the historical collection parameter selects the collection QPS of each blockchain node, and the network resource parameter selects the network delay. When the network delay is not greater than the specified value, the transaction on-chain TPS and collection QPS at the corresponding moment are obtained. The historical transmission parameters, historical collection parameters, and historical network resource parameters can also select one or more other parameters, which will not be repeated here. The selected preset model is trained using the feature set, and the model parameters are adjusted by the optimization algorithm to maximize the prediction accuracy of the preset model. In the case of minimizing the loss function, it is judged that the preset model converges, and the training of the preset model is stopped. The preset model learns the mapping relationship between the transmission parameters and the maximum collection parameters that the current network resources can bear through iteration.

[0061] In this embodiment, the mapping relationship between the transmission parameters and the maximum acquisition parameters that the current network resources can bear is accurately learned through a preset model, thereby improving the accuracy of acquiring the acquisition parameters.

[0062] Training a preset model according to a feature set includes: dividing the feature set to obtain a training set and a validation set; training the preset model according to the training set, and evaluating the trained preset model according to the validation set to obtain an evaluation result of the preset model; and adjusting parameters of the preset model according to the evaluation result.

[0063] Among them, part of the data selected from the feature set is used as the training set, and part of the data that does not overlap with the training set is selected as the validation set. Optionally, after the model is trained using the training set, the model parameters are adjusted by optimization algorithms such as gradient descent until the loss function is minimized, and the performance of the model is evaluated by the validation set. Alternatively, the feature set is divided into K subsets, and the model is trained with K-1 subsets each time, and the remaining 1 subset is used for verification. Repeat the execution K times, and rotate the validation set each time. The evaluation index of the model performance is obtained by combining the K verification results, and K is an integer greater than 1. Among them, the evaluation results include but are not limited to performance estimation parameters such as prediction accuracy, mean square error, etc. for evaluating the similarity between the model prediction value and the true value. Optionally, after obtaining the evaluation results, by comparing the performance of the preset model under different parameter combinations on the validation set, find the model parameter configuration, feature selection, and model structure with the highest prediction accuracy, and adjust the parameters of the preset model based on this configuration.

[0064] Optionally, adjusting the parameters of the preset model mainly includes: separating high-load nodes and low-load nodes in the blockchain by adjusting the parameters, which means that tasks on high-load nodes can be rerouted to low-load nodes to ensure that there is no single point overload, thereby optimizing the topology of the blockchain network by adjusting the parameters of the model deployed on the blockchain. Adjusting the parameters of the preset model also includes: if a node is determined to be facing a high load according to the evaluation results, reducing the collection QPS of the node to avoid an increase in network delay.

[0065] In this embodiment, the trained preset model is evaluated based on the validation set, and the parameters of the preset model are adjusted according to the evaluation results, thereby improving the generalization ability of the preset model, avoiding model overfitting, and further improving the accuracy of the acquisition parameters obtained by converting the transmission parameters through the preset mapping relationship.

[0066] In some of the embodiments, collecting block headers of blocks in a target data source based on collection parameters includes: comparing a block range of blocks to be collected in the target data source with a threshold range; and when the block range is greater than or equal to the threshold range, collecting block headers of blocks in the target data source based on the collection parameters.

[0067] Among them, the threshold range is used to indicate whether the amount of data of the block to be collected in the target data source exceeds the transmission capacity of the current blockchain network transaction on-chain process, and the value of the threshold range can be set according to the application requirements. If the block range of the block to be collected in the target data source is less than the threshold range, the data to be collected is small, and the time spent on collecting all the data is short, and the browser page can be quickly loaded based on the collected data. If the block range of the block to be collected in the target data source is greater than or equal to the threshold range, the data to be collected is large, and the time spent on collecting all the data is long, the node load is high, and the browser page cannot be quickly loaded based on the collected data, causing the problem of poor data collection performance.

[0068] Optionally, when the block range is smaller than the threshold range, the data of the entire block is directly taken; when the block range is greater than or equal to the threshold range, the step of collecting the block header of the block in the target data source is executed, and when the block header of the block is collected, the block body of the block is collected.

[0069] In this embodiment, the data collection method is adjusted according to the comparison result between the block range and the threshold range, which not only avoids the problem of excessively high or low node load, but also realizes fast data acquisition and browser page loading.

[0070] In some of the embodiments, before collecting the block header of the block in the target data source based on the collection parameters, the method also includes: obtaining the connection status of each blockchain node in the target data source; and removing the blockchain nodes with abnormal connection status in the target data source.

[0071] The connection status of a blockchain node is used to indicate whether the node can interact with other nodes or maintain network connectivity. Optionally, the node connection status can be obtained by viewing the node's log file to obtain node failure information, or by monitoring the port status, resource usage, node consensus status, etc.

[0072] Before collecting the block header of the block in the target data source based on the collection parameters, the method also includes: each blockchain node in the target data source queries the block hash value of the latest block at the same height; if there is a target blockchain node in the target data source whose query result of the block hash value is inconsistent with the block hash value obtained by the query of the majority of nodes that meet the consensus fault tolerance rule, then remove the target blockchain node from the target data source. Optionally, the blockchain node obtains the block hash value through a command line interface or an API interface.

[0073] Among them, the latest block refers to the block that has been recently added to the blockchain network. The consensus fault tolerance rule refers to the mechanism by which the entire blockchain network can still operate normally and reach a consensus on the data status even if some blockchain nodes have errors or malicious behaviors. After obtaining the consensus algorithm corresponding to the target data source, the corresponding consensus fault tolerance rule and the maximum number of Byzantine nodes can be determined. The block hash values ​​of the latest blocks of the same height obtained by querying the majority of nodes that meet the consensus fault tolerance rule are consistent. The target blockchain node is inconsistent with the block hash value obtained by querying the majority of nodes that meet the consensus fault tolerance rule. These target blockchain nodes may have problems such as malicious tampering, network synchronization failure, and database damage. They are Byzantine nodes. Remove these Byzantine nodes from the target data source to update the target data source.

[0074] Optionally, before collecting the block header of the block in the target data source based on the collection parameters, not only the blockchain nodes with abnormal connection status are removed, but also the Byzantine nodes are determined according to the block hash value obtained by querying the blockchain node, and the Byzantine nodes are removed.

[0075] In this embodiment, by removing abnormal blockchain nodes before collecting block data, it is avoided that abnormal blockchain nodes cause erroneous data in the collected data, thereby improving the accuracy and consistency of data collection.

[0076] In some of the embodiments, after removing at least one blockchain node from the target data source, the method includes: performing anomaly detection on the target data source according to preset rules, and generating warning information according to the anomaly detection result.

[0077] Among them, the preset rules are used to detect whether the target data source has been subjected to external fraud, attacks and other abnormal behaviors. Based on the preset rules, the connection status, connectable node status and hash values ​​of each block of the target data source can be detected to obtain abnormal detection results, and early warning information can be generated based on the detection results.

[0078] Exemplarily, the preset rules are used to instruct the terminal to execute the steps: connect to all nodes in the blockchain network. If there is a node connection failure, an early warning message is generated: "Unable to establish a connection with the <node hostname> node, please handle it in time."

[0079] Optionally, after executing the step of connecting all nodes in the blockchain network, the preset rules may also instruct the terminal to execute the steps of: querying the status of connectable nodes, and generating warning information according to the status of connectable nodes. Among them, if there are nodes in a non-"normal" state, and the number of nodes in a non-"normal" state is less than or equal to the fault tolerance number of the corresponding consensus algorithm, a warning message is generated: "<node hostname> node status is abnormal, please handle it in time". If there are nodes in a non-normal state, and the number of nodes in a non-normal state is greater than the fault tolerance number of the corresponding consensus algorithm, a warning message is generated: "<chain name> The number of abnormal nodes is greater than the number of consensus fault tolerance nodes, please handle it in time", and all abnormal nodes and abnormal reasons are listed in the generated warning information.

[0080] Optionally, the preset rule is used to instruct the terminal to execute the step: query the latest block hash of the normal node. If there is an inconsistency in the hash of the block at the same height, and the number of inconsistent nodes plus the number of non-normal nodes is less than or equal to the fault tolerance number of the corresponding consensus algorithm, a warning message is generated: "The block hash of <node hostname> is inconsistent with other nodes in the cluster, please handle it in time". If there is an inconsistency in the block hash at the same height, and the number of inconsistent nodes plus the number of non-normal nodes is greater than the fault tolerance number of the corresponding consensus algorithm, a warning message is generated: "The number of abnormal nodes of <chain name> is greater than the number of consensus fault tolerance nodes, please handle it in time", and all abnormal nodes and abnormal reasons are listed in the generated warning message. Alternatively, when executing the step of querying the latest block hash of the normal node, the step of connecting to all nodes in the blockchain network or the step of querying the status of connectable nodes can also be executed synchronously or asynchronously.

[0081] Optionally, after generating the early warning information, according to the early warning feedback and processing results, the preset rules and algorithms are optimized to improve the accuracy and efficiency of the early warning. For example, when executing blockchain data collection, different types of heterogeneous chains may be connected, and different heterogeneous chains may use different consensus algorithms. The fault tolerance calculation rules corresponding to each consensus algorithm are different. For example, n is taken as the total number of nodes participating in the consensus, and f is taken as the maximum number of tolerable Byzantine fault nodes. In order to ensure that consensus is reached, the number of nodes participating in the consensus based on the PBFT algorithm is at least: n≥3f+1; in order to ensure that consensus is reached, the number of nodes participating in the consensus based on the RADT algorithm is at least: n≥2f+1. Therefore, if a new consensus algorithm is added when connecting different types of heterogeneous chains, the corresponding fault tolerance calculation rules need to be added accordingly. At the same time, if the original or newly added blockchain network contains non-consensus nodes, it is necessary to adjust the preset rules to filter out the non-consensus nodes.

[0082] In some of the embodiments, a blockchain browser adaptive collection method is provided, which dynamically adjusts the parameters and methods of data collection based on the results of real-time monitoring and analysis, combined with preset rules and algorithms, to adapt to different situations and needs and improve the efficiency and accuracy of data collection.

[0083] Figure 3 A flowchart of a blockchain browser adaptive collection method is provided. Figure 3 As shown, the following steps are included:

[0084] Step S301, initialization: set the initial monitoring parameters, monitor and obtain parameter indicators such as node status, transaction chain TPS, block height, etc.

[0085] Step S302, real-time monitoring: monitor the status and changes of the target data source, including the status of blockchain nodes, transaction TPS, network latency, block height, data collection status and other indicators.

[0086] Step S303, data analysis: analyzing the monitoring results and evaluating the adaptability of the current data collection parameters according to preset data analysis rules and algorithms.

[0087] Figure 4 A flowchart of a blockchain data analysis method is provided. Figure 4 As shown, the blockchain data analysis method includes:

[0088] Query the node status. If the node status is not "normal", remove the nodes with connection failure or abnormal status in the data source to update the data source and push the information to the warning trigger module.

[0089] When the node status is queried to be "normal", the node is judged to be a normally connected node, and the node's latest block hash value is queried. Among them, querying the latest block hash value of the node includes: querying the latest block hash value from all available blockchain nodes in the data source. If there is an inconsistency in the block hash value queried by the blockchain node, then according to the consensus mechanism, or through network monitoring and analysis of behaviors that do not conform to the expected pattern, or analyzing the topological structure of the blockchain network to find potential malicious node clusters or abnormal network activities, etc., find the Byzantine node, remove the Byzantine node from the data source, and update the data source. Optionally, the relevant information of the Byzantine node can also be pushed to the warning trigger module to generate warning information.

[0090] If there are no Byzantine nodes on the blockchain network or the number of Byzantine nodes is within the fault tolerance of the consensus algorithm, the block hash values ​​are consistent, the block height is updated, and the block range R that needs to be collected is determined. If the collected block range R is less than the threshold range M, the complete block data is collected; if the collected block range R is greater than or equal to the threshold range M, the block header is collected first and then the block body. This setting is because the block header usually contains metadata information of the block, such as block height, timestamp, hash value of the previous block, etc. This information is very important for building the main functions of the blockchain browser. Based on the block header, the latest block in the browser page, the legitimacy of the block can be verified, and other overview information can be displayed. In addition, the block header is relatively small, so it is faster and more efficient to collect, thereby realizing the rapid loading and display of the browser page. The block body contains transaction data and any other information stored in the blockchain. Since the block body may be very large, it takes more time and resources to collect and process the block body. Therefore, the collection method can be dynamically adjusted according to the algorithm and the block range R to be collected.

[0091] During the collection process, the collection QPS of different nodes is adjusted according to the algorithm results: combining machine learning and artificial intelligence technologies, the collection QPS of different nodes in the data source is adjusted according to historical data and real-time feedback such as transaction chain TPS, node network delay, etc.

[0092] Optionally, the adjustment of the node collection QPS by machine learning methods and artificial intelligence technology includes:

[0093] Collect and preprocess data. Collect historical transmission data, historical collection data, and historical network resource data of each block in the target data source; the collected data includes but is not limited to indicators such as transaction chain TPS and node network delay. Preprocess the data, including removing outliers and standardizing processing, to facilitate the application of subsequent machine learning algorithms.

[0094] Perform feature engineering based on the processed data: Based on the collected data, construct a feature set, which may include parameters used to indicate the historical performance of the node, the network topology, the node hardware configuration, and other characteristics.

[0095] Train the model based on the feature set: Use the feature set to train the selected machine learning model and adjust the model parameters to maximize the prediction accuracy. Evaluate the adjusted model, optimize the model feature selection, model structure, model hyperparameters, etc. based on the evaluation results, obtain the machine learning model for real-time prediction of the acquisition parameters of different nodes, and deploy the trained model to the system.

[0096] Real-time prediction and adjustment of collection parameters based on trained models: Based on the real-time detected transmission parameters, such as transaction on-chain TPS, node network latency, network topology, etc., update the input data of the model, and use the prediction results of the model output to adjust the collection parameters of each node. According to the analysis results, dynamically adjust the parameters of data collection, including the collected blockchain nodes, block collection methods, collection QPS, etc. According to the adjusted parameters, perform data collection operations to obtain data from the target data source. After the block data is collected, perform data verification and synchronization operations to ensure that the collected data is consistent with the data in the blockchain network. Optionally, by verifying the hash value of the block, the validity of the transaction and other data verification methods, ensure that the collected blockchain data is consistent with the data of other nodes.

[0097] Repeat the above process according to the specified cycle or in response to user instructions, continuously optimize the model based on the monitored data, and obtain the latest collection parameters in real time to optimize the data collection strategy.

[0098] Step S304, judging whether the node status of the blockchain node is abnormal according to the data analysis results, if the node status is abnormal, executing step S305; if the node status is normal, executing step S306. Optionally, after judging whether the node status of the blockchain node is abnormal according to the data analysis results, the nodes with failed connection or abnormal status are removed from the data source according to the status of the blockchain node. Among them, the abnormal detection result of the node can be obtained by obtaining the connection status of each node in the blockchain, the status of the blockchain connectable nodes, and the latest block hash of the node in the "normal" state. Specifically, nodes that cannot be connected in the blockchain network, nodes whose node status does not belong to "normal", and nodes whose block hash is inconsistent with the hash of other blocks of the same height are all abnormal nodes.

[0099] Step S305, early warning triggering: triggering an early warning mechanism according to the abnormal nodes detected, generating early warning information and notifying relevant personnel. Optionally, generating early warning information includes: in the case of detecting abnormal nodes, listing all abnormal nodes and abnormal causes, and obtaining early warning information for notifying relevant personnel.

[0100] Step S306, feedback optimization: collect warning information, optimize and adjust the detection rules and algorithms of abnormal nodes, and improve the accuracy and efficiency of warning. Optionally, if there is a new consensus algorithm, add the calculation rules of the number of Byzantine node fault tolerance corresponding to the consensus algorithm to optimize the algorithm; if the original or newly added blockchain network contains non-consensus nodes, it is necessary to adjust the preset rules to filter out non-consensus nodes to adjust the rules.

[0101] Exemplarily, warning triggering and feedback are achieved by setting an intelligent warning strategy. The intelligent warning strategy is implemented by a warning trigger module and a feedback optimization module. The warning trigger module is used to trigger the warning mechanism according to the abnormal detection results, generate warning information and notify relevant personnel. The feedback optimization module is used to optimize the warning rules and algorithms according to the warning feedback and processing results to improve the accuracy and efficiency of the warning.

[0102] The smart early warning strategy is as follows: Set the initial early warning rules and parameters. According to the detection results in step S304, determine whether the early warning condition is triggered. For example, if the node status of the blockchain node is determined to be abnormal, the early warning condition is triggered, and early warning information is generated and notified to relevant personnel. Send the early warning information to relevant personnel or teams, and the early warning information includes but is not limited to: early warning type, triggering reason, recommended treatment measures, etc. Collect early warning feedback and processing results, optimize and adjust the early warning rules and algorithms according to the feedback and processing results, and improve the accuracy and efficiency of early warning.

[0103] Step S307, parameter adjustment: dynamically adjust data collection parameters according to the data analysis results, such as: collected blockchain nodes, block collection method, collection QPS, etc.

[0104] Step S308, collection and execution, and after the execution is completed, step S302 is executed. The collection and execution refers to executing the data collection operation according to the adjusted parameters to obtain the required data.

[0105] Optionally, after the block data is collected, data verification and synchronization operations are performed to ensure that the collected data is consistent with the data in the blockchain network, including verifying the hash value of the block, the validity of the transaction, etc., to ensure that the collected blockchain data is consistent with the data of other nodes. At the same time, a corresponding fault recovery mechanism is designed for possible faults that may occur during the data collection process.

[0106] Exemplarily, the blockchain browser adaptive collection method in this embodiment can be implemented based on a real-time monitoring module, an analysis and decision module, and a collection execution module. Among them, the real-time monitoring module is used to monitor the status of cluster nodes, transaction chain TPS, block height and other indicators, and provide real-time feedback to the collection system; step S301 is executed based on the real-time monitoring module. The analysis and decision module is used to analyze and decide on data collection parameters based on monitoring results and preset rules, and determine parameters such as collection methods and frequencies; steps S302 to S307 are executed based on the analysis and decision module. The collection execution module is used to perform corresponding data collection operations and obtain required data according to the instructions of the analysis and decision module; step S308 is executed based on the collection execution module.

[0107] In this embodiment, the network environment, resource load, block collection range and other parameters of different nodes are monitored in real time to adjust the block data collection method, and the trained machine learning model outputs the collection QPS in real time according to the detected parameters, so as to achieve the effect of ensuring data collection performance. At the same time, the self-node abnormal monitoring is realized through the intelligent early warning strategy to avoid the collection of abnormal data, and the reliability of the collected data is guaranteed without affecting the blockchain network cluster. Specifically, according to the real-time monitoring parameters and data analysis results, the data collection parameters are dynamically adjusted to adapt to different blockchain network environments; according to the actual collection block range, the collection method is flexibly adjusted to improve the efficiency and accuracy of data collection; by removing abnormal nodes, unnecessary data collection and resource waste are avoided, and the utilization rate of system resources is improved; combined with machine learning technology, the collection and early warning strategies are continuously optimized to improve the degree of intelligence in the data collection process.

[0108] It should be understood that, although each step in the flow chart involved in each embodiment as above is shown in turn according to the indication of arrows, these steps are not necessarily performed in turn according to the order indicated by arrows. Unless there is clear explanation in this article, the execution of these steps does not have strict order restriction, and these steps can be performed in other orders. And, at least a portion of steps in the flow chart involved in each embodiment as above can include multiple steps or multiple stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these steps or stages is not necessarily performed in turn, but can be performed in turn or alternately with at least a portion of the steps or stages in other steps or other steps. For example, can be when executing steps such as data analysis, parameter adjustment, the step of real-time detection is performed.

[0109] Based on the same inventive concept, the embodiment of the present application also provides a blockchain data collection device for implementing the blockchain data collection method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more blockchain data collection device embodiments provided below can refer to the limitations of the blockchain data collection method above, and will not be repeated here.

[0110] In one embodiment, Figure 5 As shown, a blockchain data collection device is provided, including: a parameter acquisition module, a first collection module and a second collection module, wherein:

[0111] The parameter acquisition module is used to obtain the acquisition parameters obtained by converting the transmission parameters through a preset mapping relationship; wherein the transmission parameters are the parameters when the data of the target data source is uploaded to the blockchain network corresponding to the browser page, and the mapping relationship is used to characterize the relationship between the transmission parameters and the maximum acquisition parameters that the current network resources can bear;

[0112] A first collection module, used to collect the block header of the block in the target data source according to the collection parameters, and update the metadata data of the block in the browser page based on the block header;

[0113] The second collection module is used to collect the block body of the block based on the collection parameters when the block header of the blockchain node is collected, and update the transaction data of the block in the browser page based on the block body.

[0114] In some of the embodiments, the parameter acquisition module acquires the mapping relationship, including: constructing a feature set according to the historical transmission parameters when acquiring the target data source, the historical network resource parameters corresponding to the historical transmission parameters, and the historical acquisition parameters; training the preset model according to the feature set; and obtaining the mapping relationship according to the preset model when the preset model converges. Optionally, training the preset model according to the feature set includes: dividing the feature set to obtain a training set and a validation set; training the preset model according to the training set, and evaluating the trained preset model according to the validation set to obtain an evaluation result of the preset model; and adjusting the parameters of the preset model according to the evaluation result.

[0115] In some of the embodiments, the first acquisition module acquires block headers of blocks in the target data source based on acquisition parameters, including: comparing a block range of the blocks to be acquired in the target data source with a threshold range; and when the block range is greater than or equal to the threshold range, acquiring block headers of the blocks in the target data source based on the acquisition parameters.

[0116] In some of the embodiments, before the first collection module collects the block header of the block in the target data source based on the collection parameters, the method also includes: obtaining the connection status of each blockchain node in the target data source; and removing the blockchain nodes with abnormal connection status in the target data source.

[0117] In some of the embodiments, before the first collection module collects the block header of the block in the target data source based on the collection parameters, the method also includes: each blockchain node in the target data source queries the block hash value of the latest block at the same height; if there is a target blockchain node in the target data source whose block hash value query result is inconsistent with the block hash value obtained by querying the majority of nodes that meet the consensus fault tolerance rules, then the target blockchain node is removed from the target data source.

[0118] In some of the embodiments, the blockchain data collection device also includes an early warning module, which is used to perform anomaly detection on the target data source according to preset rules after removing at least one blockchain node from the target data source, and generate early warning information based on the anomaly detection results.

[0119] Each module in the above-mentioned blockchain data collection device can be implemented in whole or in part by software, hardware and their combination. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0120] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store target data source data, browser page data, early warning information, etc. for implementing the data in the above method embodiment. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a blockchain data collection method is implemented.

[0121] Those skilled in the art will understand that Figure 6The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0122] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0123] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0124] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0125] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0126] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0127] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A blockchain data collection method, characterized in that: The method comprises: Obtaining acquisition parameters obtained by converting transmission parameters through a preset mapping relationship; wherein the transmission parameters are parameters when the data of the target data source is uploaded to the blockchain network corresponding to the browser page, and the mapping relationship is used to characterize the relationship between the transmission parameters and the maximum acquisition parameters that the current network resources can bear; Collecting a block header of a block in the target data source according to the collection parameters, and updating meta information data of the block in the browser page based on the block header; When the block header of the blockchain node is collected, the block body of the block is collected based on the collection parameters, and the transaction data of the block is updated in the browser page based on the block body.

2. The method according to claim 1, characterized in that Obtaining the mapping relationship includes: Constructing a feature set according to historical transmission parameters when collecting the target data source, historical network resource parameters corresponding to the historical transmission parameters, and historical collection parameters; Training a preset model according to the feature set; When the preset model converges, the mapping relationship is obtained according to the preset model.

3. The method according to claim 2, characterized in that The step of training a preset model according to the feature set includes: Dividing the feature set to obtain a training set and a validation set; Training the preset model according to the training set, and evaluating the trained preset model according to the validation set to obtain an evaluation result of the preset model; The parameters of the preset model are adjusted according to the evaluation results.

4. The method according to claim 1, characterized in that: The step of collecting the block header of the block in the target data source based on the collection parameter includes: Comparing the block range of the block to be collected in the target data source with the threshold range; When the block range is greater than or equal to the threshold range, the block header of the block is collected in the target data source based on the collection parameter.

5. The method according to claim 1, characterized in that Before collecting the block header of the block in the target data source based on the collection parameter, the method further includes: Obtain the connection status of each blockchain node in the target data source; The blockchain node with abnormal connection status is removed from the target data source.

6. The method according to claim 1, characterized in that Before collecting the block header of the block in the target data source based on the collection parameter, the method further includes: Each blockchain node in the target data source queries the block hash value of the latest block at the same height; If there is a target blockchain node in the target data source whose query result of the block hash value is inconsistent with the block hash value obtained by querying the majority of nodes that meet the consensus fault tolerance rules, the target blockchain node is removed from the target data source.

7. The method according to claim 5 or 6, characterized in that: After removing at least one of the blockchain nodes from the target data source, the method includes: Anomaly detection is performed on the target data source according to preset rules, and warning information is generated according to the anomaly detection results.

8. A blockchain data collection device, characterized in that: The device comprises: A parameter acquisition module is used to obtain the acquisition parameters obtained by converting the transmission parameters through a preset mapping relationship; wherein the transmission parameters are the parameters when the data of the target data source is uploaded to the blockchain network corresponding to the browser page, and the mapping relationship is used to characterize the relationship between the transmission parameters and the maximum acquisition parameters that the current network resources can bear; A first collection module, configured to collect a block header of a block in the target data source according to the collection parameter, and update the meta information data of the block in the browser page based on the block header; The second collection module is used to collect the block body of the block based on the collection parameters when the block header of the blockchain node is collected, and update the transaction data of the block in the browser page based on the block body.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.