Blockchain-based time-consuming monitoring method, device, equipment and medium

By using custom monitoring annotations and software development kit configurations, time-consuming monitoring scripts corresponding to blockchain nodes are generated, solving the problem of low efficiency in existing time-consuming monitoring technologies and achieving efficient real-time monitoring of blockchain nodes and accurate judgment of abnormal states.

CN114510399BActive Publication Date: 2026-02-10SHENZHEN PING AN SMART HEALTHCARE TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210146382.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-17
Publication Date
2026-02-10
Estimated Expiration
2042-02-17

AI Technical Summary

Technical Problem

Existing technologies for monitoring the time consumption of blockchain nodes are inefficient and require writing time consumption monitoring scripts for each node, resulting in a large workload and a high risk of errors.

Method used

By generating time-consuming monitoring scripts corresponding to blockchain nodes and configuring custom monitoring annotations in the scripts, the monitoring nodes are configured using a software development kit, and the node operation information is collected in real time, reducing the repetitive work of manually writing scripts.

Benefits of technology

It improves the efficiency of monitoring the time consumption of blockchain nodes, enhances the accuracy of monitoring information collection and feedback time, and realizes real-time monitoring of nodes and timely judgment of abnormal status.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114510399B_ABST
    Figure CN114510399B_ABST
Patent Text Reader

Abstract

The application provides a blockchain-based time consumption monitoring method and device, an electronic device and a storage medium. The blockchain-based time consumption monitoring method comprises the following steps: obtaining node information of a blockchain node based on a time consumption monitoring request issued by the blockchain node, wherein the node information comprises a category identifier and IP information of the blockchain node; generating a time consumption monitoring script corresponding to the blockchain node according to the node information, and configuring a self-defined monitoring annotation for the blockchain node in the time consumption monitoring script; running the time consumption monitoring script and collecting time consumption information of the blockchain node according to the monitoring annotation; and obtaining a running state of the blockchain node based on the time consumption information of the blockchain node. The application adaptively changes a to-be-monitored node in the blockchain node through the monitoring annotation, thereby monitoring the running time of the blockchain node in real time and improving the time consumption monitoring efficiency of the blockchain node.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of artificial intelligence, and particularly relates to a time consumption monitoring method and device based on a blockchain, an electronic device and a storage medium. BACKGROUND

[0002] With the increasing size and complexity of the blockchain, the number of running nodes thereof is also increasing. Since the data size in the blockchain nodes is huge and the content is disordered, it is difficult for a user to check whether the running time of each blockchain node is abnormal.

[0003] In the prior art, the collection of the running time of each node of the blockchain is achieved by writing a corresponding time consumption monitoring script for the blockchain node to be monitored. Therefore, a corresponding time consumption monitoring script needs to be written for each blockchain node to be monitored. This method not only has a large amount of work, but also is prone to errors, resulting in low efficiency of time consumption monitoring of the blockchain nodes. SUMMARY

[0004] In view of the above, it is necessary to propose a time consumption monitoring method based on a blockchain and related devices to solve the technical problem of how to improve the time consumption monitoring efficiency of the blockchain nodes, wherein the related devices include a time consumption monitoring device based on a blockchain, an electronic device and a storage medium.

[0005] The present application provides a time consumption monitoring method based on a blockchain, which comprises:

[0006] acquiring node information of a blockchain node based on a time consumption monitoring request issued by the blockchain node, wherein the node information comprises a category identifier and IP information of the blockchain node;

[0007] generating a time consumption monitoring script corresponding to the blockchain node according to the node information, and configuring a custom monitoring annotation for the blockchain node in the time consumption monitoring script;

[0008] running the time consumption monitoring script and collecting time consumption information of the blockchain node according to the monitoring annotation;

[0009] acquiring a running state of the blockchain node based on the time consumption information of the blockchain node.

[0010] In this way, the to-be-monitored node in the blockchain node is adaptively changed through the monitoring annotation, so that the running time of the blockchain node is monitored in real time, without the need to write a corresponding time consumption monitoring script for each blockchain node, a large amount of repetitive work is reduced, and the time consumption monitoring efficiency of the blockchain node is improved.

[0011] In some embodiments, the generating the time-consuming monitoring script corresponding to the blockchain node according to the node information and configuring the customized monitoring annotations for the blockchain node in the time-consuming monitoring script comprises:

[0012] generating the time-consuming monitoring script corresponding to the blockchain node information;

[0013] setting the to-be-monitored nodes, the to-be-monitored nodes being the methods in the time-consuming monitoring script, and each blockchain node corresponding to a time-consuming monitoring script including a plurality of to-be-monitored nodes;

[0014] configuring the customized monitoring annotations for the to-be-monitored nodes based on a software development kit.

[0015] Thus, since the monitoring annotations can be run in real time along with the running of the to-be-monitored nodes to obtain the detailed information of the to-be-monitored nodes at runtime, the collection accuracy of the running information of the to-be-monitored nodes is improved, and the feedback time of the information can be effectively reduced to realize real-time monitoring and feedback of the monitoring indicators of the to-be-monitored nodes. The monitoring indicators include the runtime, usage rate, read-write rate, and memory occupancy rate of the to-be-monitored nodes.

[0016] In some embodiments, the generating the time-consuming monitoring script corresponding to the blockchain node information comprises:

[0017] determining the monitoring resources of the blockchain node that need to be monitored according to the category identifier, the monitoring resources being the running data of the blockchain node;

[0018] generating the time-consuming monitoring script corresponding to the blockchain node according to the monitoring resources of the blockchain node that need to be monitored and the IP information of the blockchain node.

[0019] Thus, the corresponding time-consuming monitoring script can be generated according to the monitoring resources of the blockchain node that need to be monitored and the IP information of the blockchain node, so that the resource categories of the blockchain node that need to be monitored can be accurately monitored.

[0020] In some embodiments, the running the time-consuming monitoring script and collecting the time-consuming information of the blockchain node according to the monitoring annotations comprises:

[0021] compiling the codes in the time-consuming monitoring script to obtain a bytecode file;

[0022] loading the bytecode file into a Java virtual machine;

[0023] scanning the bytecode file based on the Java virtual machine to obtain the to-be-monitored nodes containing all the monitoring annotations;

[0024] modify bytecode of the to-be-monitored node based on the monitoring annotation to obtain an updated class file;

[0025] run the updated class file to collect time-consuming information of the blockchain node.

[0026] In this way, the to-be-monitored node of the time-consuming monitoring script can be fundamentally changed by the monitoring annotation, without the need for manual writing of a corresponding time-consuming monitoring script for each to-be-monitored node, reducing manual repetitive operations and improving the time-consuming monitoring efficiency of the to-be-monitored node.

[0027] In some embodiments, the modifying the bytecode of the to-be-monitored node based on the monitoring annotation to obtain an updated class file comprises:

[0028] parsing the bytecode of the to-be-monitored node by a bytecode modification tool to obtain an original binary byte array;

[0029] modifying the original binary byte array by the monitoring annotation to obtain an updated binary byte array;

[0030] writing the updated binary byte array into a local disk to generate the updated class file.

[0031] In this way, the bytecode of the to-be-monitored node is modified by the existing bytecode modification tool, thereby generating the updated class file, without the need for manual writing of a corresponding script to modify the bytecode of the to-be-monitored node, effectively improving the modification efficiency of the bytecode of the to-be-monitored node.

[0032] In some embodiments, the running the updated class file to collect time-consuming information of the blockchain node comprises:

[0033] when the to-be-monitored node in the updated class file is running, collecting time-consuming information of the to-be-monitored node in a manner indicated by the monitoring annotation of the to-be-monitored node as the time-consuming information of the blockchain node; the time-consuming information of the to-be-monitored node comprises at least two of a running duration, a running start time, or a running end time of the to-be-monitored node.

[0034] In this way, each to-be-monitored node can annotate different parameters for the method in the time-consuming monitoring script according to the manner indicated by the corresponding monitoring annotation, so that various parameters and values annotated in different methods can be obtained, and at the same time, by collecting the time-consuming information of the to-be-monitored node, the detailed time-consuming information of the blockchain node can be accurately grasped in real time.

[0035] In some embodiments, the obtaining the running state of the blockchain node based on the time-consuming information of the blockchain node comprises:

[0036] acquire a maximum running duration in the historical running durations corresponding to each to-be-monitored node in the blockchain node;

[0037] If the running duration of all to-be-monitored nodes is less than the corresponding maximum running duration, the running state of the blockchain node is normal; if the running duration of any to-be-monitored node is greater than the corresponding maximum running duration, the running state of the blockchain node is abnormal, and a message is sent to the server.

[0038] In this way, since the code running speed in the to-be-monitored node is related to the processor of the compiled code, the running state of the blockchain node can be effectively determined by comparing the running duration of the to-be-monitored node with the maximum running duration in the corresponding historical running duration.

[0039] Embodiments of the present application also provide a time-consuming monitoring device based on a blockchain, comprising:

[0040] An acquisition unit is configured to acquire node information of a blockchain node based on a time-consuming monitoring request issued by the blockchain node, wherein the node information comprises a category identifier and IP information of the blockchain node;

[0041] A generation unit is configured to generate a time-consuming monitoring script corresponding to the blockchain node according to the node information, and configure a customized monitoring annotation for the blockchain node in the time-consuming monitoring script;

[0042] An acquisition unit is configured to run the time-consuming monitoring script and acquire time-consuming information of the blockchain node according to the monitoring annotation;

[0043] The acquisition unit is further configured to acquire a running state of the blockchain node based on the time-consuming information of the blockchain node.

[0044] Embodiments of the present application also provide an electronic device, comprising:

[0045] A memory is configured to store at least one instruction;

[0046] A processor is configured to execute the instruction stored in the memory to implement the time-consuming monitoring method based on a blockchain.

[0047] Embodiments of the present application also provide a computer readable storage medium, wherein the computer readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor in an electronic device to implement the time-consuming monitoring method based on a blockchain. BRIEF DESCRIPTION OF DRAWINGS

[0048] Figure 1 is a flowchart of a preferred embodiment of the time-consuming monitoring method based on a blockchain involved in the present application.

[0049] Figure 2 is a flow chart of a preferred embodiment of the present application related to generating a time-consuming monitoring script corresponding to a blockchain node according to node information, and configuring a customized monitoring note for the blockchain node in the time-consuming monitoring script.

[0050] Figure 3 is a flow chart of a preferred embodiment of the present application related to running a time-consuming monitoring script and collecting time-consuming information of a blockchain node according to a monitoring note.

[0051] Figure 4 is a function module diagram of a preferred embodiment of a blockchain-based time-consuming monitoring device related to the present application.

[0052] Figure 5 is a structural schematic diagram of an electronic device of a preferred embodiment of a blockchain-based time-consuming monitoring method related to the present application. DETAILED DESCRIPTION

[0053] In order to more clearly understand the purpose, features and advantages of the present application, the present application will be described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict. In the following description, a large number of specific details are set forth in order to facilitate a full understanding of the present application, and the described embodiments are only some of the embodiments of the present application, but not all the embodiments.

[0054] In addition, the terms "first", "second" are only for the purpose of description, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with "first", "second" can explicitly or implicitly include one or more of the features. In the description of the present application, the meaning of "a plurality of" is two or more, unless otherwise specifically limited.

[0055] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the present application belongs. The terms used in the specification of the present application are only for the purpose of describing the specific embodiments of the present application, and are not intended to limit the present application. The term "and / or" used herein includes any and all combinations of one or more related listed items.

[0056] This application provides a blockchain-based time-consuming monitoring method that can be applied to one or more electronic devices. An electronic device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions. Its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0057] Electronic devices can be any electronic product that allows human-computer interaction with a customer, such as personal computers, tablets, smartphones, personal digital assistants (PDAs), game consoles, interactive network television (IPTV), smart wearable devices, etc.

[0058] Electronic devices may also include network devices and / or client devices. The network devices include, but are not limited to, a single network server, a server group consisting of multiple network servers, or a cloud based on cloud computing consisting of a large number of hosts or network servers.

[0059] The networks in which electronic devices are located include, but are not limited to, the Internet, wide area networks, metropolitan area networks, local area networks, and virtual private networks (VPNs).

[0060] like Figure 1 The diagram shown is a flowchart of a preferred embodiment of the blockchain-based time-consuming monitoring method of this application. Depending on different requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted.

[0061] S10: Obtain the node information of the blockchain node based on the time consumption monitoring request issued by the blockchain node. The node information includes the category identifier and IP information of the blockchain node.

[0062] In an optional embodiment, a blockchain node that needs to monitor time consumption can send a time consumption monitoring request as a signal to request time consumption monitoring settings.

[0063] When the electronic device receives the time-consuming monitoring request issued by the blockchain node, the node information of the blockchain node is acquired, and the node information includes the category identifier and IP information of the blockchain node. The category identifier of the blockchain node is an identifier used to indicate the type of the blockchain node. The blockchain nodes in the same blockchain network can be divided into different types, for example, the blockchain nodes can be divided into public nodes, private nodes, broadcast nodes, full nodes, and mining nodes, and each type of blockchain node corresponds to a category identifier.

[0064] In an optional embodiment, letters can be used as the category identifier of the blockchain node, for example, the category identifier corresponding to the public node is R, the category identifier corresponding to the private node is P, and the like. In another example, numbers can be used as the category identifier of the blockchain node, for example, the category identifier corresponding to the public node is 1, the category identifier corresponding to the private node is 2, and the like. The present example does not make special limitations on this.

[0065] In the optional embodiment, the IP information refers to the IP address of the blockchain node, and the category identifier and the IP information of the blockchain node can uniquely determine the blockchain node and its category.

[0066] In this way, the time-consuming monitoring script corresponding to the category identifier can be generated for the blockchain nodes of different types according to the category identifier of the blockchain node, and the IP information of the blockchain node ensures the uniqueness of the blockchain node information, which facilitates the generation of the time-consuming monitoring script corresponding to the blockchain node.

[0067] S11, a time-consuming monitoring script corresponding to the blockchain node is generated according to the node information, and a custom monitoring annotation for the blockchain node is configured in the monitoring script.

[0068] Please refer to Figure 2 In an optional embodiment, generating a time-consuming monitoring script corresponding to the blockchain node according to the node information and configuring a custom monitoring annotation for the blockchain node in the monitoring script includes:

[0069] S111, a time-consuming monitoring script corresponding to the blockchain node information is generated.

[0070] In the optional embodiment, the time-consuming monitoring script generated due to the uniqueness of the node information corresponds to the blockchain node.

[0071] In the optional embodiment, first, the monitoring resource that needs to be monitored by the blockchain node can be determined according to the category identifier, and the monitoring resource refers to the running data of the blockchain node, such as the usage rate, the usage percentage, etc. of the blockchain node. Different kinds of blockchain nodes need to be monitored by different monitoring resources, for example, the monitoring resource that needs to be monitored by the public node is the usage rate and the accounting times, and the monitoring resource that needs to be monitored by the private node is the memory occupancy rate and the read-write rate.

[0072] In the optional embodiment, second, when the monitoring resource that needs to be monitored by the blockchain node is determined, the time-consuming monitoring script corresponding to the blockchain node is generated according to the monitoring resource that needs to be monitored by the blockchain node and the IP information of the blockchain node.

[0073] S112, setting a to-be-monitored node, the to-be-monitored node being a method in the time-consuming monitoring script, and each blockchain node corresponding to a time-consuming monitoring script including a plurality of to-be-monitored nodes.

[0074] In an optional embodiment, the to-be-monitored node is set in the time-consuming monitoring script, and the to-be-monitored node is a method in the time-consuming monitoring script. A method is a small program in a class for completing an independent function. Since each time-consuming monitoring script corresponding to each blockchain node includes a plurality of methods, each blockchain node can correspond to a plurality of to-be-monitored nodes.

[0075] S113, configuring a customized monitoring annotation for the to-be-monitored node based on a software development kit.

[0076] In an optional embodiment, the customized monitoring annotation is used to identify which monitoring nodes in the monitoring script need to be annotated. The annotation is actually a kind of mark, which can be marked in the time-consuming monitoring script (such as a method in the program). Then the program can detect these marks when compiling or running to perform some special operations, that is, it is equivalent to marking some marks in the script program, so that the program can process according to these annotations.

[0077] For example, by performing the customized monitoring annotation on the to-be-monitored node in the time-consuming monitoring script of the blockchain node, when we run the program, we can return the abnormal information {code: 500323, msg: “service timeout”} through the url (** / order). When we view the to-be-monitored node, it is difficult to know the running time of the current program node. If the customized monitoring annotation is marked, such as (historical order interface, / order, {code: 500323, msg: “service timeout”}), it can be easily located that what problem the program node has.

[0078] In the optional embodiment, the monitoring annotation can be regarded as a template for extending a method, each method annotates different parameters according to the rules in the annotation class, and different parameters and values annotated in different methods can be obtained at the place where the monitoring annotation is used. The monitoring annotation can be read at the time of compilation, class loading, and running, and corresponding processing can be performed. After the monitoring annotation is written, the monitoring annotation can be added to the corresponding code, and supplementary information can be embedded in the source code without changing the original code and logic. Since the monitoring annotation and the node to be monitored run synchronously, the situation of the node to be monitored can be obtained in real time.

[0079] For example, the custom monitoring annotation of a method in the time-consuming monitoring script is as follows:

[0080] @Retention(RetentionPolicy.RUNTIME)

[0081] @Target(ElementType.FIELD)

[0082] public@interface CostTime{

[0083] }

[0084] In the optional embodiment, the software development kit is generally a collection of development tools established by some software engineers for a specific software package, software framework, hardware platform, operating system, etc.

[0085] In the optional embodiment, the software development kit can be loaded into the file of the time-consuming monitoring script, and the monitoring annotation corresponding to the code segment running on the node to be monitored can be created according to the software development kit. The monitoring annotation also runs synchronously when the corresponding code segment of the node to be monitored runs, thereby monitoring the node to be monitored.

[0086] Therefore, since the monitoring annotation can run in real time with the node to be monitored to obtain detailed information of the node to be monitored when the node to be monitored runs, the collection accuracy of the running information of the node to be monitored is improved, and the feedback time of the information can be effectively reduced, thereby realizing real-time monitoring and feedback of the monitoring indicators of the node to be monitored. The monitoring indicators include the running time, usage rate, read-write rate, and memory occupancy rate of the node to be monitored.

[0087] S12, running the time-consuming monitoring script and collecting the time-consuming information of the blockchain node according to the monitoring annotation.

[0088] Please refer to Figure 3 In an optional embodiment, running the time-consuming monitoring script and collecting the time-consuming information of the blockchain node according to the monitoring annotation includes:

[0089] S121, compile the code in the time-consuming monitoring script to obtain a bytecode file.

[0090] In this optional embodiment, running the time-consuming monitoring script is the process of compiling the code in the time-consuming monitoring script. Through the compiler, the source code of the time-consuming monitoring script is first subjected to lexical analysis, the character stream of the source code is converted into a set of tokens, then syntax analysis is performed, the token sequence is used to construct an abstract syntax tree, the symbol table is filled, and finally, through semantic analysis, the context-relatedness of the source program that is correct in the syntax structure is examined, the information generated in the previous steps is converted into bytecode, and finally the obtained bytecode file is written into the disk corresponding to the current blockchain node.

[0091] In this optional embodiment, a single character is the smallest element in the program writing process, and a token is the smallest element in the compilation process, keywords, variable names, literals, and operators can all become tokens; the abstract syntax tree is a tree representation method used to describe the syntax structure of program code, each node of the syntax tree represents a syntax structure in the program code, such as types, modifiers, operators, etc.; the symbol table is a table composed of a group of symbol addresses and symbol information, the content registered in the symbol table will be used for semantic checking and intermediate code generation, and when the symbol name is subjected to address allocation in the target code generation stage, the symbol table is the basis for address allocation.

[0092] S122, load the bytecode file into a java virtual machine.

[0093] S123, based on the java virtual machine, scan the bytecode file to obtain a to-be-monitored node containing all monitoring annotations.

[0094] In this optional embodiment, the bytecode file content is scanned by the java virtual machine to find all to-be-monitored nodes containing the custom monitoring annotations in the time-consuming monitoring script, at this time, the bytecode of these to-be-monitored nodes can be modified.

[0095] S124, based on the monitoring annotations, modify the bytecode of the to-be-monitored node to obtain an updated class file.

[0096] In this optional embodiment, based on the monitoring annotations, modifying the bytecode of the to-be-monitored node to obtain an updated class file includes: parsing the bytecode of the to-be-monitored node to obtain an original binary byte array according to a bytecode modification tool; calling the monitoring annotations to modify the original binary byte array to obtain an updated binary byte array; and writing the updated binary byte array into a local disk to generate the updated class file.

[0097] In an optional embodiment, the bytecode modification tool can use ASM. For java bytecode, it is generated in the compilation process of a Java class, i.e. the process from a.java source file to a.class binary bytecode file, and the loading of the Java class is to obtain a binary byte stream through the name of the class, and then generate a class object in the memory by the byte stream. Therefore, the timing of dynamically modifying the class is to modify the.class file, and the purpose of modifying the class can be achieved by modifying the bytecode of the.class file.

[0098] In this optional embodiment, the ASM framework provides three special classes, namely ClassReader, ClassWriter and ClassVisitor. ClassReader can parse the class file and convert it into a binary array. For the method, annotation and parameter of the class, etc., they are provided as visitXxx method parameters of the ClassVisitor class. ClassWriter is a subclass of ClassVisitor, which can convert the binary array into a compiled class file. ClassVisitor is a description of a class, which can delegate visitXxx methods to another ClassVisitor. The ClassVisitor has multiple visitXxx methods, which are used to parse different structures of the class and modify the content of the class by using the custom monitoring annotation. Finally, a new.class file is generated through ClassWriter.

[0099] In this optional embodiment, the time-consuming monitoring script file modified by the bytecode is used as an updated class file to collect the time-consuming information of each to-be-monitored node according to the monitoring annotation.

[0100] S125, running the updated class file to collect the time-consuming information of the blockchain node.

[0101] In an optional embodiment, when the to-be-monitored node in the updated class file is running, the time-consuming information of the to-be-monitored node is collected as the time-consuming information of the blockchain node in the manner indicated by the monitoring annotation of the to-be-monitored node. The time-consuming information of the to-be-monitored node includes at least two of the running duration, the running start time or the running end time of the to-be-monitored node.

[0102] In the embodiment, the monitoring annotation in the above embodiment is generated, and SpringAOP needs to be used. AOP is an abbreviation of AspectOriented Programming, which means AspectOriented Programming. A technology that realizes unified maintenance of program functions through pre-compiled and dynamic proxy during running. We first need to import the package of spring bootstarter aop, and based on the use of the @Around annotation of Spring, the monitoring annotation in the above embodiment can be written to obtain the running start time and end time of the to-be-monitored node in real time. In addition, the running duration of the to-be-monitored node can also be calculated by using the start time and end time when the end time is obtained. Of course, the @Before annotation and the @After annotation of Spring can also be used to write the monitoring annotation in the above embodiment to realize at least two of obtaining the running duration, the running start time or the end time of the to-be-monitored node.

[0103] In this optional embodiment, the modification of the class file is realized by modifying the bytecode, so that the time-consuming monitoring script can output the monitoring information of each to-be-monitored program node. For example, record the current time before program execution as the start time of program execution, record the current time after program execution as the end time of program execution, and calculate the time difference between the end time and the start time to obtain the time-consuming of a program execution in the blockchain node.

[0104] For example, before the program node is called and run by the blockchain node, the start timestamp (such as November 12, 2021, 15:16:35, 155 milliseconds) is recorded, and the end timestamp (such as November 12, 2021, 15:16:35, 655 milliseconds) is recorded when the program node runs. The time-consuming of the current program node can be obtained by subtracting the start timestamp from the end timestamp (such as 655 milliseconds-155 milliseconds=500 milliseconds).

[0105] In this way, the to-be-monitored node of the time-consuming monitoring script can be fundamentally changed by the monitoring annotation, and there is no need to manually write a corresponding time-consuming monitoring script for each to-be-monitored node, reducing manual repetitive operations and improving the efficiency of time-consuming monitoring of to-be-monitored nodes.

[0106] S13, obtaining the running state of the blockchain node based on the time-consuming information of the blockchain node.

[0107] In an optional embodiment, the obtaining of the running state of the blockchain node based on the time-consuming information of the blockchain node comprises:

[0108] S131, counting the maximum running duration in the historical running duration corresponding to each to-be-monitored node in the blockchain node.

[0109] In an optional embodiment, after continuously collecting the monitoring indicators of each to-be-monitored node over time, the running state of each to-be-monitored node can be analyzed according to the monitoring indicators in each to-be-monitored node. For example, the monitoring indicator is the running duration of the to-be-monitored node. Since the code running speed in the to-be-monitored node is related to the processor of the compiled code, when the processor remains in a stable state, the running duration corresponding to the running path of the code in the to-be-monitored node is generally stable. Even if there is a loop code in the to-be-monitored node, there will be a maximum running duration in the historical running duration. Therefore, the running duration of the to-be-monitored node can be compared with the previously obtained running duration, and whether the to-be-monitored node is abnormal can be determined according to whether the running duration is too long.

[0110] S132, if the running duration of all to-be-monitored nodes is less than the corresponding maximum running duration, the running state of the blockchain node is normal; if the running duration of any to-be-monitored node is greater than the corresponding maximum running duration, the running state of the blockchain node is abnormal, and an abnormal notification is sent to the server.

[0111] Therefore, since the code running speed in the to-be-monitored node is related to the processor of the compiled code, the running state of the blockchain node can be effectively determined by comparing the running duration of the to-be-monitored node with the maximum running duration in the corresponding historical running duration.

[0112] In an optional embodiment, the time-consuming monitoring method based on the blockchain further includes determining whether to send a warning information based on the running state of the blockchain node.

[0113] In an optional embodiment, when the server receives the abnormal notification that the running state of the blockchain node is abnormal, a warning information can be immediately sent, and the warning information further includes the IP information of the blockchain node in the abnormal state and the corresponding monitoring resource name, so that the staff can quickly lock the abnormal part of the blockchain node.

[0114] Therefore, by determining the running state of the blockchain node in real time, the warning information can be sent in time to prevent the abnormal blockchain node from causing further harm and improve the security of the blockchain node running.

[0115] Please refer to Figure 4 , Figure 4is a functional module diagram of a preferred embodiment of a blockchain-based time-consuming monitoring device of the present application. The blockchain-based time-consuming monitoring device 11 comprises an acquisition unit 110, a generation unit 111, and a collection unit 112. The module / unit referred to in the present application refers to a series of computer-readable instruction segments capable of being executed by the processor 13 and capable of completing a fixed function, which is stored in the memory 12. In the present embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.

[0116] In an optional embodiment, the acquisition unit 110 is configured to acquire node information of a blockchain node based on a time-consuming monitoring request issued by the blockchain node, wherein the node information comprises a category identifier and IP information of the blockchain node.

[0117] In an optional embodiment, the blockchain node that needs to be subjected to time-consuming monitoring can send a time-consuming monitoring request as a signal for requesting time-consuming monitoring settings.

[0118] When the electronic device receives the time-consuming monitoring request issued by the blockchain node, the node information of the blockchain node is acquired, wherein the node information comprises a category identifier and IP information of the blockchain node. The category identifier of the blockchain node is an identifier used to indicate the type of the blockchain node. The blockchain nodes in the same blockchain network can be divided into different types, for example, the blockchain nodes can be divided into public nodes, private nodes, broadcast nodes, full nodes, and mining nodes, etc., and each type of blockchain node corresponds to a category identifier.

[0119] In an optional embodiment, letters can be used as the category identifier of the blockchain node, for example, the category identifier corresponding to the public node is R, the category identifier corresponding to the private node is P, etc. In another example, numbers can be used as the category identifier of the blockchain node, for example, the category identifier corresponding to the public node is 1, the category identifier corresponding to the private node is 2, etc. The present example does not make special limitations on this.

[0120] In the optional embodiment, the IP information refers to the IP address of the blockchain node, and the category identifier and the IP information of the blockchain node can be used to uniquely determine the blockchain node and its category.

[0121] In an optional embodiment, the generation unit 111 is configured to generate a time-consuming monitoring script corresponding to the blockchain node according to the node information, and configure a customized monitoring annotation for the blockchain node in the time-consuming monitoring script.

[0122] In an optional embodiment, generating a time-consuming monitoring script corresponding to the blockchain node according to the node information and configuring a customized monitoring annotation for the blockchain node in the time-consuming monitoring script comprises:

[0123] generating a time-consuming monitoring script corresponding to the blockchain node information;

[0124] setting a to-be-monitored node, the to-be-monitored node being a method in the time-consuming monitoring script, and each blockchain node corresponding to a time-consuming monitoring script including a plurality of to-be-monitored nodes;

[0125] configuring a customized monitoring annotation for the to-be-monitored node based on a software development kit.

[0126] In an optional embodiment, a time-consuming monitoring script corresponding to the blockchain node is generated according to the node information, and a customized monitoring annotation for the blockchain node is configured in the monitoring script.

[0127] In the optional embodiment, the time-consuming monitoring script generated corresponds to the blockchain node due to the uniqueness of the node information.

[0128] In the optional embodiment, the monitoring resource that needs to be monitored for the blockchain node can be determined according to the category identifier first, and the monitoring resource refers to the running data of the blockchain node, such as the usage rate, usage percentage, etc. of the blockchain node. Different kinds of blockchain nodes need to be monitored for different monitoring resources, for example, the usage rate and the number of accountings need to be monitored for a public node, and the memory occupancy rate and the read-write rate need to be monitored for a private node.

[0129] In the optional embodiment, when the monitoring resource that needs to be monitored for the blockchain node is determined, a time-consuming monitoring script corresponding to the blockchain node is generated according to the monitoring resource that needs to be monitored for the blockchain node and the IP information of the blockchain node.

[0130] In an optional embodiment, a to-be-monitored node is set in the time-consuming monitoring script, the to-be-monitored node being a method in the time-consuming monitoring script, and a method being a small program in a class for completing an independent function. Therefore, each blockchain node can correspond to a plurality of to-be-monitored nodes since the time-consuming monitoring script corresponding to each blockchain node includes a plurality of methods.

[0131] In an optional embodiment, the customized monitoring annotation is used to identify which monitoring nodes in the monitoring script need to be annotated. The annotation is actually a kind of mark, which can be marked in the time-consuming monitoring script (such as a method in a program), and then the program can detect these marks when compiling or running to perform some special operations, that is, some marks are marked in the script program, so that the program can perform corresponding processing according to these annotations.

[0132] For example, through the time-consuming monitoring script of the blockchain node, the node to be monitored is customized with monitoring annotations. When we run the program, we can return the abnormal information {code: 500323, msg: "service timeout"} through the url (** / order). When we check the node to be monitored, it is difficult to know the running time of the current program node. If the monitoring annotations are customized and marked, such as (historical order interface, / order, {code: 500323, msg: "service timeout"}), we can easily locate the problem of the program node.

[0133] In the optional embodiment, the monitoring annotation can be regarded as a template for extending a method. Each method annotates different parameters according to the rules in the annotation class. In the place where it is used, different parameters and values annotated in different methods can be obtained. The annotation can be read at the time of compilation, class loading and running, and the corresponding processing can be performed. After writing the annotation, the annotation is added to the corresponding code. The supplementary information can be embedded in the source code without changing the original code and logic. Since the monitoring annotation and the node to be monitored are run synchronously, the condition of the node to be monitored can be obtained in real time.

[0134] For example, the custom monitoring annotation of a method in the time-consuming monitoring script is as follows:

[0135] @Retention(RetentionPolicy.RUNTIME)

[0136] @Target(ElementType.FIELD)

[0137] public@interface CostTime{

[0138] }

[0139] In the optional embodiment, the software development kit is generally a collection of development tools for software engineers when they develop application software for specific software packages, software frameworks, hardware platforms, operating systems, etc.

[0140] In the optional embodiment, the software development kit can be loaded into the file of the time-consuming monitoring script, and the corresponding monitoring annotation can be created according to the code segment of the software development kit running on the node to be monitored, and the monitoring annotation is also synchronized to run to complete the monitoring of the node to be monitored when the corresponding code segment of the node to be monitored runs; the reference relationship can also be created according to the software development kit in the parent class of the node to be monitored, and the corresponding code block of the software development kit is added to the parent class as an attribute of the parent class, so that when the node to be monitored is created by using the parent class, the corresponding code block of the software development kit will also run to create the corresponding monitoring annotation.

[0141] The acquisition unit 112 is configured to run the time-consuming monitoring script and acquire the time-consuming information of the blockchain node according to the monitoring annotation.

[0142] In an optional embodiment, running the time-consuming monitoring script and acquiring the time-consuming information of the blockchain node according to the monitoring annotation comprises:

[0143] Compiling the code in the time-consuming monitoring script to obtain a bytecode file;

[0144] Loading the bytecode file into a Java virtual machine;

[0145] Scanning the bytecode file based on the Java virtual machine to obtain a node to be monitored containing all monitoring annotations;

[0146] Modifying the bytecode of the node to be monitored based on the monitoring annotation to obtain an updated class file;

[0147] Running the updated class file to acquire the time-consuming information of the blockchain node.

[0148] In the optional embodiment, running the time-consuming monitoring script is a process of compiling the code in the time-consuming monitoring script. Through the compiler, the source code of the time-consuming monitoring script is first subjected to lexical analysis, the character stream of the source code is converted into a set of tokens, then syntax analysis is performed, the token sequence is used to construct an abstract syntax tree, the symbol table is filled, and finally, through semantic analysis, the context-relatedness of the source program is reviewed, and the information generated in the previous steps is converted into bytecode and written to the disk.

[0149] In the optional embodiment, a single character is the smallest element in the program writing process, and the token is the smallest element in the compiling process, and the keyword, variable name, literal and operator can be the token; the abstract syntax tree is a tree representation used to describe the syntax structure of the program code, and each node of the syntax tree represents a syntax structure in the program code, such as type, modifier, operator and the like; the symbol table is a table composed of a group of symbol addresses and symbol information, and the content registered in the symbol table will be used for semantic checking and intermediate code generation, and when the address allocation is performed on the symbol name in the target code generation stage, the symbol table is the basis for the address allocation.

[0150] In the optional embodiment, the java virtual machine scans the bytecode file content to find all the to-be-monitored nodes containing the customized monitoring annotation in the time-consuming monitoring script, and the bytecode of the to-be-monitored nodes can be modified at this time.

[0151] In the optional embodiment, the bytecode of the to-be-monitored node is modified based on the monitoring annotation to obtain the updated class file, which includes: the bytecode of the to-be-monitored node is parsed by the bytecode modification tool to obtain an original binary byte array; the original binary byte array is modified by calling the monitoring annotation to obtain an updated binary byte array; and the updated binary byte array is written into a local disk to generate the updated class file.

[0152] In an optional embodiment, the bytecode modification tool can use ASM. For the java bytecode, it is generated in the compiling process of the Java class, that is, the process from the.java source file to the.class binary bytecode file, and the loading of the Java class is to obtain the binary byte stream through the name of the class, and then generate the class object from the byte stream in the memory. Therefore, the timing of dynamically modifying the class is to modify the.class file, and as long as the bytecode of the.class file is modified, the purpose of modifying the class can be achieved.

[0153] In the optional embodiment, the ASM framework provides three special classes, namely ClassReader, ClassWriter and ClassVisitor. The ClassReader can parse the class file and convert it into a binary array. For the method, annotation, parameter and other contents of the class, the ClassVisitor is provided as the visitXxx method parameter of the ClassVisitor class. The ClassWriter is a subclass of the ClassVisitor, which can convert the binary array into a compiled class file. The ClassVisitor is a description of a class, which can delegate the visitXxx method to another ClassVisitor. The ClassVisitor has multiple visitXxx methods, which are used to parse different structures of the class and modify the class content by using the custom monitoring annotation. Finally, the new.class file is generated by the ClassWriter.

[0154] In the optional embodiment, the time-consuming monitoring script file modified by the bytecode is used as an updated class file to collect the time-consuming information of each to-be-monitored node according to the monitoring annotation.

[0155] In an optional embodiment, when the to-be-monitored node in the updated class file runs, the time-consuming information of the to-be-monitored node is collected as the time-consuming information of the blockchain node in the manner indicated by the monitoring annotation of the to-be-monitored node. The time-consuming information of the to-be-monitored node includes at least two of the running duration, the running start time or the running end time of the to-be-monitored node.

[0156] In the embodiment, the monitoring annotation in the above embodiment is generated by using SpringAOP. AOP is the abbreviation of AspectOriented Programming, which means AspectOriented Programming. It is a technology that realizes the unified maintenance of program functions through pre-compiled and dynamic proxy during running. First, we need to import the package of spring bootstarter aop. Based on the use of the @Around annotation of Spring, the monitoring annotation in the above embodiment can be written to obtain the running start time and end time of the to-be-monitored node in real time. In addition, the running duration of the to-be-monitored node can also be calculated by using the start time and end time when the end time is obtained. Of course, the @Before annotation and the @After annotation of Spring can also be used to write the monitoring annotation in the above embodiment to realize the acquisition of at least two of the running duration, the running start time or the running end time of the to-be-monitored node.

[0157] In the optional embodiment, the modification of the class file is achieved by modifying the bytecode, so that the time-consuming monitoring script can output the monitoring information of each program node to be monitored, such as recording the current time before program execution as the start time of program execution, recording the current time after program execution as the end time of program execution, and calculating the time difference between the end time and the start time to obtain the time-consuming of a certain program execution in the blockchain node.

[0158] For example, before the program node is called and run by the blockchain node, the start time stamp (such as November 12, 2021, 15:16:35, 155 milliseconds) is recorded, and the end time stamp (such as November 12, 2021, 15:16:35, 655 milliseconds) is recorded when the program node ends. The time-consuming of the current program node can be obtained by subtracting the start time stamp from the end time stamp (such as 655 milliseconds-155 milliseconds=500 milliseconds).

[0159] In an optional embodiment, the acquisition unit 110 is further configured to acquire the running state of the blockchain node based on the time-consuming information of the blockchain node.

[0160] In an optional embodiment, acquiring the running state of the blockchain node based on the time-consuming information of the blockchain node comprises:

[0161] statistically determining the maximum running duration from the historical running durations of each to-be-monitored node in the blockchain node;

[0162] If the running duration of all to-be-monitored nodes is less than the corresponding maximum running duration, the running state of the blockchain node is normal; if the running duration of any to-be-monitored node is greater than the corresponding maximum running duration, the running state of the blockchain node is abnormal, and the server is sent.

[0163] In an optional embodiment, after continuously collecting the monitoring indicators of each to-be-monitored node over time, the running state of each to-be-monitored node can be analyzed according to the monitoring indicators in each to-be-monitored node. For example, the monitoring indicator is the running duration of the to-be-monitored node. Since the code running speed in the to-be-monitored node is related to the processor that compiles the code, when the processor remains in a stable state, the running duration corresponding to the running path of the code in the to-be-monitored node is generally stable. Even if there is a to-be-monitored node with loop code, there will be a maximum running duration in the historical running duration. Therefore, the running duration of the to-be-monitored node can be compared with the previously obtained running duration, and whether the to-be-monitored node is abnormal can be determined according to whether the running duration is too long.

[0164] In an optional embodiment, the time-consuming monitoring method based on the blockchain further comprises determining whether to send a warning message based on the running state of the blockchain node.

[0165] In an optional embodiment, when the server receives the exception notification that the running state of the blockchain node is abnormal, a warning information can be immediately sent out, and the warning information further includes the IP information and the corresponding monitoring resource name of the blockchain node in the abnormal state, so that the staff can quickly lock the abnormal part of the blockchain node.

[0166] From the above technical solutions, it can be seen that the present application can adaptively change the to-be-monitored node in the blockchain node through the monitoring annotation, thereby monitoring the running time of the blockchain node in real time, without the need to write a corresponding time-consuming monitoring script for each blockchain node, thereby reducing a large amount of repetitive work, and further improving the time-consuming monitoring efficiency of the blockchain node.

[0167] Please refer to Figure 5 is a structural schematic diagram of an electronic device provided by an embodiment of the present application. The electronic device 1 includes a memory 12 and a processor 13. The memory 12 is used to store computer readable instructions, and the processor 13 is used to execute the computer readable instructions stored in the memory to implement the blockchain-based time-consuming monitoring method described in any of the above embodiments.

[0168] In an optional embodiment, the electronic device 1 further includes a bus, a computer program stored in the memory 12 and executable on the processor 13, such as a blockchain-based time-consuming monitoring program.

[0169] Figure 5 Only the electronic device 1 with the memory 12 and the processor 13 is shown, and those skilled in the art can understand that Figure 5 The structure shown does not constitute a limitation on the electronic device 1, and can include fewer or more components than shown, or combine certain components, or different component arrangements.

[0170] In combination with Figure 1 The memory 12 in the electronic device 1 stores a plurality of computer readable instructions to implement a blockchain-based time-consuming monitoring method, and the processor 13 can execute the plurality of instructions to implement:

[0171] Obtain node information of the blockchain node based on a time-consuming monitoring request issued by the blockchain node, the node information including a category identifier and IP information of the blockchain node;

[0172] Generate a time-consuming monitoring script corresponding to the blockchain node according to the node information, and configure a custom monitoring annotation for the blockchain node in the time-consuming monitoring script;

[0173] Run the time-consuming monitoring script and collect time-consuming information of the blockchain node according to the monitoring annotation;

[0174] Obtain the running state of the blockchain node based on the time-consuming information of the blockchain node.

[0175] Specifically, the specific implementation method of the processor 13 to the above instructions can refer to Figure 1 The description of related steps in the corresponding embodiments will not be repeated here.

[0176] Those skilled in the art can understand that the schematic diagram is only an example of the electronic device 1 and does not constitute a limitation on the electronic device 1. The electronic device 1 can be a bus type structure or a star type structure. The electronic device 1 can also include more or less other hardware or software, or different component arrangements, for example, the electronic device 1 can also include an input / output device, a network access device, etc.

[0177] It should be noted that the electronic device 1 is only an example. Other existing or future electronic products, such as those adaptable to the present application, should also be included in the protection scope of the present application and are hereby incorporated by reference.

[0178] The memory 12 includes at least one type of readable storage medium, which can be non-volatile or volatile. The readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (e.g., an SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, etc. The memory 12 can be an internal storage unit of the electronic device 1 in some embodiments, such as a mobile hard disk of the electronic device 1. The memory 12 can also be an external storage device of the electronic device 1 in other embodiments, such as a plug-in mobile hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. The memory 12 can be used to store application software and various data installed in the electronic device 1, such as the code of the time-consuming monitoring program based on the blockchain, and can also be used to temporarily store data that has been output or will be output.

[0179] The processor 13 can be composed of integrated circuits in some embodiments, for example, can be composed of a single packaged integrated circuit, or can be composed of multiple packaged integrated circuits with the same function or different functions, including one or more central processing units (CPU), microprocessors, digital processing chips, graphics processors, combinations of various control chips, etc. The processor 13 is the control core of the electronic device 1, which connects all components of the electronic device 1 through various interfaces and lines, executes programs or modules stored in the memory 12 (such as executing a blockchain-based time-consuming monitoring program, etc.), and calls data stored in the memory 12 to execute various functions of the electronic device 1 and process data.

[0180] The processor 13 executes the operating system of the electronic device 1 and various installed application programs. The processor 13 executes the application programs to implement the steps in each of the above blockchain-based time-consuming monitoring method embodiments, such as Figures 1 to 3 The steps shown.

[0181] For example, the computer program can be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 13 to complete the present application. The one or more modules / units can be a series of computer-readable instruction segments that can complete a specific function, which are used to describe the execution process of the computer program in the electronic device 1. For example, the computer program can be divided into an acquisition unit 110, a generation unit 111, and a collection unit 112.

[0182] The integrated units implemented in the form of software function modules described above can be stored in a computer-readable storage medium. The software function modules described above are stored in a storage medium, including a plurality of instructions for causing a computer device (which can be a personal computer, a computer device, or a network device, etc.) or a processor to execute part of the blockchain-based time-consuming monitoring method described in each embodiment of the present application.

[0183] The modules / units integrated in the electronic device 1, if implemented in the form of software function units and sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above-mentioned embodiments can also be instructed by a computer program to complete related hardware devices, and the computer program can be stored in a computer-readable storage medium. The computer program, when executed by a processor, can implement the steps of each of the above method embodiments.

[0184] The computer program includes computer program code in the form of source code, object code, executable files, or some intermediate form, etc. The computer readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory, and other memories, etc.

[0185] Further, the computer readable storage medium can mainly include a storage program area and a storage data area, wherein the storage program area can store an operating system, an application required by at least one function, etc.; and the storage data area can store data created according to the use of the blockchain node, etc.

[0186] The blockchain referred to in the present application is a new application mode of distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm and other computer technologies. The blockchain is essentially a decentralized database, which is a series of data blocks associated using cryptographic methods, each data block contains the information of a batch of network transactions, and is used to verify the validity (anti-fake) of the information and generate the next block. The blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer, etc.

[0187] The bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For convenience of representation, only one arrow is used in Figure 5 , but it does not mean that there is only one bus or only one type of bus. The bus is arranged to realize the connection and communication between the memory 12, the at least one processor 13, etc.

[0188] The embodiment of the present application also provides a computer readable storage medium (not shown in the figure), which stores computer readable instructions. The computer readable instructions are executed by the processor in the electronic device to realize the time-consuming monitoring method based on the blockchain in any of the above embodiments.

[0189] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. In actual implementation, there can be another division manner.

[0190] The modules described as separate components may or may not be physically separate, and the components displayed as modules may or may not be physical units, i.e., may be located in one place, or may be distributed to multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment scheme.

[0191] In addition, each functional module in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of hardware plus software functional modules.

[0192] In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. The plurality of units or devices stated in the specification can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names and do not mean any specific order.

[0193] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and not to limit it, although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present application can be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present application.

Claims

1. A blockchain-based time consumption monitoring method, characterized in that, The method includes: The node information of the blockchain node is obtained by issuing a time-consuming monitoring request. The node information includes the category identifier and IP information of the blockchain node. Based on the node information, a time-consuming monitoring script corresponding to the blockchain node is generated, and a custom monitoring annotation for the blockchain node is configured in the time-consuming monitoring script. This includes: generating a time-consuming monitoring script corresponding to the node information; determining the monitoring resources that the blockchain node needs to monitor based on the category identifier, where the monitoring resources refer to the blockchain node's operational data; generating a time-consuming monitoring script corresponding to the blockchain node based on the monitoring resources that the blockchain node needs to monitor and the blockchain node's IP information; setting nodes to be monitored, where the nodes to be monitored are the methods in the time-consuming monitoring script, and each blockchain node's time-consuming monitoring script includes multiple nodes to be monitored; and configuring custom monitoring annotations for the nodes to be monitored based on a software development kit (SDK). Run the time consumption monitoring script and collect the time consumption information of the blockchain node according to the monitoring annotation; The operating status of the blockchain node is obtained based on the time consumption information of the blockchain node.

2. The blockchain-based time-consuming monitoring method as described in claim 1, characterized in that, The process of running the time-consuming monitoring script and collecting the time-consuming information of the blockchain node based on the monitoring annotations includes: Compile the code in the time-consuming monitoring script to obtain the bytecode file; Load the bytecode file into the Java Virtual Machine; The Java Virtual Machine scans the bytecode file to obtain the nodes to be monitored, which contain all monitoring annotations. Modify the bytecode of the node to be monitored based on the monitoring annotation to obtain the updated class file; Run the update class file to collect the time consumption information of the blockchain node.

3. The blockchain-based time-consuming monitoring method as described in claim 2, characterized in that, The step of modifying the bytecode of the node to be monitored based on the monitoring annotation to obtain the update class file includes: The bytecode of the node to be monitored is parsed using a bytecode modification tool to obtain the original binary byte array; The monitoring annotation is invoked to modify the original binary byte array to obtain an updated binary byte array; The updated binary byte array is written to the local disk to generate the updated class file.

4. The blockchain-based time-consuming monitoring method as described in claim 3, characterized in that, The time consumption information for running the update class file to collect the blockchain node includes: When the node to be monitored in the update class file runs, the time consumption information of the node to be monitored is collected in accordance with the method indicated by the monitoring annotation of the node to be monitored as the time consumption information of the blockchain node; wherein, the method indicated by the monitoring annotation includes: the built-in indicator acquisition method carried in the software development kit corresponding to the monitoring annotation; the time consumption information of the node to be monitored includes at least two of the following: the runtime of the node to be monitored, the start time of the run, or the end time of the run.

5. The blockchain-based time-consuming monitoring method as described in claim 1, characterized in that, The process of obtaining the operating status of the blockchain node based on the time consumption information of the blockchain node includes: The maximum runtime of each monitored node in the blockchain is calculated from its historical runtime. If the runtime of all monitored nodes is less than the corresponding maximum runtime, the blockchain node is in normal operating status; if the runtime of any monitored node is greater than the corresponding maximum runtime, the blockchain node is in abnormal operating status.

6. A blockchain-based time consumption monitoring device, characterized in that, include: The acquisition unit is used to acquire the node information of the blockchain node based on the time consumption monitoring request issued by the blockchain node. The node information includes the category identifier and IP information of the blockchain node. A generation unit is configured to generate a time-consuming monitoring script corresponding to the blockchain node based on the node information, and configure custom monitoring annotations for the blockchain node in the time-consuming monitoring script. This includes: generating a time-consuming monitoring script corresponding to the node information; determining the monitoring resources that the blockchain node needs to monitor based on the category identifier, where the monitoring resources refer to the blockchain node's operational data; generating a time-consuming monitoring script corresponding to the blockchain node based on the monitoring resources that the blockchain node needs to monitor and the blockchain node's IP information; setting nodes to be monitored, where the nodes to be monitored are the methods in the time-consuming monitoring script, and each blockchain node's time-consuming monitoring script includes multiple nodes to be monitored; and configuring custom monitoring annotations for the nodes to be monitored based on a software development kit. The data collection unit is used to run the time consumption monitoring script and collect the time consumption information of the blockchain node according to the monitoring annotation; The acquisition unit is also used to acquire the operating status of the blockchain node based on the time consumption information of the blockchain node.

7. An electronic device, characterized in that, include: Memory, which stores computer-readable instructions; and The processor executes computer-readable instructions stored in the memory to implement the blockchain-based time-consuming monitoring method as described in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the blockchain-based time-consuming monitoring method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Program monitoring method and device, electronic equipment and storage medium

    CN113127309A