CN111061685A - Log query method and device, node equipment and storage medium - Google Patents

Log query method and device, node equipment and storage medium Download PDF

Info

Publication number
CN111061685A
CN111061685A CN201911151996.5A CN201911151996A CN111061685A CN 111061685 A CN111061685 A CN 111061685A CN 201911151996 A CN201911151996 A CN 201911151996A CN 111061685 A CN111061685 A CN 111061685A
Authority
CN
China
Prior art keywords
log
contract
target
log data
address
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201911151996.5A
Other languages
Chinese (zh)
Other versions
CN111061685B (en
Inventor
李茂材
刘区城
王宗友
孔利
周开班
刘攀
张劲松
蓝虎
时一防
朱耿良
杨常青
黄焕坤
崔嘉辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201911151996.5A priority Critical patent/CN111061685B/en
Publication of CN111061685A publication Critical patent/CN111061685A/en
Application granted granted Critical
Publication of CN111061685B publication Critical patent/CN111061685B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/14Details of searching files based on file metadata
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/182Distributed file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/389Keeping log of transactions for guaranteeing non-repudiation of a transaction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/02Banking, e.g. interest calculation or account maintenance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Abstract

The embodiment of the invention discloses a log query method, a log query device, node equipment and a storage medium, wherein the method comprises the following steps: receiving a log query request, wherein the log query request comprises a first address of a log management contract in a block chain and an identifier of target log data requested to be called; acquiring a log management contract according to the first address, wherein the log management contract comprises a second address of a precompiled contract, and the precompiled contract is used for transmitting log data generated by business transaction in a block chain of the log management contract to a preset storage position for storage; and calling a precompiled contract according to the second address by running a log management contract to acquire target log data corresponding to the identifier of the target log data from a preset storage position. The embodiment of the invention can be used for inquiring the log more conveniently.

Description

Log query method and device, node equipment and storage medium
Technical Field
The present invention relates to the field of block chain technologies, and in particular, to a log query method and apparatus, a node device, and a storage medium.
Background
As blockchain technology evolves, blockchains are used by more and more enterprises and users. In the blockchain, a user or an enterprise issues a transaction to the blockchain, node equipment in the blockchain executes a service indicated by the transaction, and stores log data generated in the process of executing the indicated service, so that a subsequent user can analyze the execution condition of the service through the log data.
Currently, most of log data in a block chain is encrypted through an MPT tree (an encrypted data authentication structure encryption algorithm) and then stored in a database in a key-value pair form. If the user wants to query the log data, the encrypted non-plaintext log data needs to be queried from the database according to the transaction hash value, the user cannot directly analyze the non-plaintext log, and the plaintext log can be obtained only by adopting a corresponding decryption method. The method for inquiring the log is relatively complicated in process and not convenient enough. Therefore, how to more conveniently query log data in a block chain becomes a hot issue of current research.
Disclosure of Invention
The embodiment of the invention provides a log query method, a log query device, node equipment and a storage medium, which can realize more convenient log query.
In one aspect, an embodiment of the present invention provides a log query method, including:
receiving a log query request, wherein the log query request comprises a first address of a log management contract in a block chain and an identifier of target log data requested to be queried;
acquiring the log management contract according to the first address, wherein the log management contract uses a second address of a precompiled contract, and the precompiled contract is used for transmitting log data generated by business transactions in the block chain from the log management contract to a preset storage position for storage;
and calling the pre-compiling contract according to the second address by running the log management contract to acquire the target log data corresponding to the identifier of the target log data from the preset storage position.
In another aspect, an embodiment of the present invention provides a log query apparatus, including:
the device comprises a receiving unit, a query unit and a query unit, wherein the receiving unit is used for receiving a log query request which comprises a first address of a log management contract in a block chain and an identification of target log data requested to be queried;
an obtaining unit, configured to obtain the log management contract according to the first address, where the log management contract includes a second address of a precompiled contract, and the precompiled contract is used to transmit log data generated by a service transaction in the block chain from the log management contract to a preset storage location for storage;
the obtaining unit is further configured to call the precompiled contract according to the second address by running the log management contract to obtain the target log data corresponding to the identifier of the target log data from the preset storage location.
In another aspect, an embodiment of the present invention provides a node device, including:
a processor adapted to implement one or more instructions; and the number of the first and second groups,
a computer storage medium storing one or more instructions adapted to be loaded by the processor and to perform the steps of:
receiving a log query request, wherein the log query request comprises a first address of a log management contract in a block chain and an identifier of target log data requested to be queried;
acquiring the log management contract according to the first address, wherein the log management contract comprises a second address of a precompiled contract, and the precompiled contract is used for transmitting log data generated by business transactions in the block chain from the log management contract to a preset storage position for storage;
and calling the pre-compiling contract according to the second address by running the log management contract to acquire the target log data corresponding to the identifier of the target log data from the preset storage position.
In yet another aspect, an embodiment of the present invention further provides a computer storage medium, where computer program instructions are stored in the computer storage medium, and when the computer program instructions are executed by a processor, the computer storage medium is configured to perform the log query method described above.
According to the embodiment of the invention, the log data generated by the business transaction in the block chain is transmitted to the preset storage position for storage through the precompiled contract. When an inquiry request aiming at target log data generated in a block chain is received, a log management contract is obtained according to a first address of a log management contract in the log inquiry request, the log management contract comprises a second address of a precompiled contract, and the target log data can be obtained from the preset storage position by calling the precompiled contract according to the second address through the inquiry log management contract. In the log query process, the target log data query is realized by calling the precompiled contract through the log management contract, so that the convenience of log query can be improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1a is a schematic diagram of a relationship between an account and a smart contract provided by an embodiment of the present invention;
FIG. 1b is a schematic diagram of a transaction being performed independent of a smart contract, according to an embodiment of the present invention;
FIG. 1c is a schematic diagram of a transaction being performed in connection with a smart contract as provided by an embodiment of the present invention;
FIG. 2a is an interaction diagram of a log management system according to an embodiment of the present invention;
FIG. 2b is an architecture diagram of a log management system according to an embodiment of the present invention;
fig. 3 is a schematic flowchart of a log query method according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating another log querying method according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a log query apparatus according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a node device according to an embodiment of the present invention.
Detailed Description
The technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
The blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism and an encryption algorithm, and is essentially a decentralized database. The main concepts involved in the blockchain include smart contracts, virtual machines, accounts, transactions, events, and logs, as described in more detail below:
intelligent contract: the intelligent contracts are the cores of the blockchain and are equivalent to automatic agents in the blockchain, and each intelligent contract corresponds to one contract address. When a transaction including a contract address is received, the intelligent contract corresponding to the contract address is activated, and the blockchain runs code corresponding to the intelligent contract.
Virtual Machine (EVM): the method is a running environment of the block chain, and the intelligent agent in the block chain runs in the virtual machine. Each node participating in the blockchain runs an EVM as part of the blockchain authentication protocol, and the virtual machine EVM is a sandbox that completely isolates external communications.
Account: the blockchain includes an external account and a contract account, the external account being controlled by the private key and having no account with which any code is associated. And a contract account is an account assigned to an intelligent contract, controlled by the contract code and having a code associated therewith. The address of the external account number is determined by the public key, while the address of the contract account is determined when the smart contract is created. Each account has a corresponding balance that can be changed by exchanges with ethernet coins sent by other users. Information interaction can be carried out between the external account and the contract account and between the contract account and the contract account. Referring to fig. 1a, an interaction diagram among an external account, a contract account, and an intelligent contract is provided for an embodiment of the present invention, a developer defines service logic of the intelligent contract through the contract account, that is, the developer deploys the intelligent contract in the contract account, and the external account may trigger execution of the intelligent contract corresponding to the contract account by sending a transaction to the contract account to complete the transaction between the accounts.
Trading: the transaction is information interaction between one account and another account, and colloquially, the transaction is a process that one account sends a signed message data packet to another account, and corresponding data is recorded and stored in a block chain. An identification of the sender of the transaction (i.e. the user owning the external account), an identification of the recipient of the transaction, the amount of resources of the transaction, and other data may be included in a transaction. Any one of the external accounts may create and sign a transaction, which may be a transfer transaction or a transaction related to a smart contract, such as a transaction used to create or trigger a smart contract, using its corresponding private key.
Event: the intelligent contract is a mechanism for communication inside and outside the chain provided by the blockchain, and can inform an off-chain component of what operation is finished in a certain transaction through a trigger event. Logging: it may be understood that the log represents the storage of events as part of a transaction receipt generated during the execution of the transaction.
In one embodiment, each transaction in the blockchain is converted into a message object to be transmitted to the EVM for execution, and in a specific implementation, when the transaction is converted into a message object, a sender identifier included in the transaction corresponds to an address of a sender account in the message object, a receiver identifier of the transaction corresponds to an address of a receiver account in the message object, and other contents may be unchanged; if the transaction is the creation or calling of the intelligent contract, the transaction is converted into a message object and then further converted into a contract object to be executed in the EVM, and in the specific implementation, when the message object is converted into the contract object, the address of a sender account in the message object corresponds to the address of a caller account in the contract object for calling the intelligent contract, the address of a receiver account in the message object corresponds to the address of a contract account in the contract object, and the transaction resource amount corresponds to the transfer value. Referring to FIG. 1b, a schematic diagram of a smart contract independent transaction being executed is provided for an embodiment of the present invention. In FIG. 1b, it is assumed that the external account issues a transfer transaction into the blockchain, which may include the identity of the sender issuing the transaction, the identity of the recipient receiving the transfer transaction, transaction resource data (i.e., the amount of transfer needed), and other data, among others. The node device of the block chain converts the transfer transaction into a message object (the specific conversion process is as described above), the message object is transmitted into the EVM for execution, and the account balance corresponding to the sender account in the EVM database is modified according to the transaction resource data during the specific execution.
Referring to FIG. 1c, a schematic diagram of a transaction being performed in connection with a smart contract is provided for an embodiment of the present invention. In fig. 1c, after the external account issues a transaction related to the smart contract into the blockchain, the transaction is converted into a message object, and further, the message object is converted into a contract object (the specific conversion process is as described above), and a code corresponding to the contract address is obtained from the database according to the contract address and then sent to the EVM for execution. Specifically, the virtual machine EVM is code corresponding to the execution of the intelligent contract by an EVM interpreter in the virtual machine. The EVM interpreter is a stack-based machine that has its own computer, stack, memory, and pool of resources gas.
In one embodiment, the smart contracts described above are all generic smart contracts that are executed in the EVM, and the specific implementation can be seen in fig. 1 b. The block chain also comprises a precompiled contract which runs outside the EVM, wherein the precompiled contract is a compromise scheme adopted in the EVM for providing some more complex library functions (mostly used for complex operations such as encryption, hash and the like), and is suitable for scenes with simple contract logic but frequent call or scenes with fixed contract logic and large calculation amount. Precompiled contracts are typically implemented in client code at the developer's client.
In a block chain, existing log data needs to be encrypted by a Merkel Patricia Tree (MPT) and finally stored in a database in a form of key-value pairs. When a user wants to inquire the log data, a request needs to be sent to the node, and the block chain finds the corresponding log data according to the transaction hash and returns the log data. Because the logs stored in the database are encrypted, the block chain needs to decrypt the acquired log data after acquiring the log data to obtain plaintext data which can be understood by the user, and then returns the plaintext data to the user, and the process of the method for inquiring the logs is complicated.
In order to solve the problems existing in the conventional log query, the embodiment of the invention provides a log management system based on a precompiled contract, so that the log query can be realized more quickly and efficiently. The following describes, by means of fig. 2a and 2b, a log management system provided by an embodiment of the present invention: fig. 2a is an interaction diagram of a log management system according to an embodiment of the present invention, where fig. 2a includes a block chain 101, a developer terminal 102 of the block chain, and a user terminal 103, where the developer terminal 102 is a terminal used by a developer of the block chain, and the user terminal 103 may be a terminal used by a user corresponding to an external account of the block chain. The blockchain 101 is a federation chain, and the blockchain includes a plurality of node devices, and the developer and the user may be the same, in which case the developer terminal 102 and the user terminal 103 are the same terminal. Fig. 2b is an architecture diagram of a log management system according to an embodiment of the present invention, in fig. 2b, 201 denotes a precompiled contract and content included in the precompiled contract, 202 denotes a log management contract and content included in the log management contract, and 203 denotes a service contract and content included in the service contract. 204 represents a file system or database for storing log data, 205 represents a log analysis system for block chain authorization, and the log analysis system 205 can perform statistics and analysis on the logs stored in the file system or database.
The developer writes a precompiled contract through the developer terminal 102, the precompiled contract corresponding to a system contract of the blockchain, and specifies an address for the precompiled contract when writing the precompiled contract, the address serving as a basis for other contracts to call the precompiled contract, in other words, other contracts can call the precompiled contract using the address. By writing a precompiled contract to implement a log data recorder, log data generated in a blockchain can be stored in a preset file or database in the form of structured data. In order to prevent other users from directly calling the precompiled contract through the address of the precompiled contract, the precompiled contract written by the developer and the address of the precompiled contract are not published outwards.
When writing a precompiled contract, a developer may write a log recording method, a log query method, and a log authority management method, as shown in 201 in fig. 2b, in the precompiled contract, so that the precompiled contract may be subsequently invoked to store a log, query the log, and manage log authority by using the corresponding methods.
In order to enable other users to call the precompiled contract to store or query the log, the developer can write a corresponding log management contract for the precompiled contract, and then show the contract address of the log management contract to the other users, so that the other users can call the precompiled contract to store or acquire corresponding log data by sending a transaction or service contract to the address of the log management contract. The address of the precompiled contract can be stored in the log management contract, and when the log management contract runs, the precompiled contract is automatically called according to the address of the precompiled contract to record or query the log. Similarly, the source code of the log management contract is also not disclosed to the outside for security, so as to prevent an illegal user from acquiring the address of the pre-compiled contract through the source code and directly calling the pre-compiled contract by bypassing the log management contract.
In one embodiment, a log management contract acts as a link between a user and a precompiled contract in which a logging method and a log query method for multiple types of log data and a list of parameters corresponding to the various methods may be stored. Optionally, the log management contract may provide an external interface for the user, and the contract address corresponding to the log management contract, the method and the corresponding parameter list included in the log management contract are displayed to the user through the external interface, so that the user may invoke the method and the corresponding parameter in the log management contract in a manner of writing a service contract or in a manner of issuing a service transaction, record log data that is desired to be recorded, or query log data that is desired to be queried.
In one embodiment, the user may record the log data desired to be recorded or query the desired log data by issuing transactions or issuing business contracts into the blockchain. If a user records a log to be recorded in a business contract writing mode, the user can specify which specific log data in the business transaction executing process need to be stored and executed by calling a precompiled contract when writing the business contract as shown in fig. 2b, and if the business to be executed by the user is a deposit or withdrawal business, when the business executing and storing business can be written in when writing the business management contract, which contents are recorded by the precompiled contract, for example, when the deposit business is executed, n (n is a positive integer) coins are transferred into the deposit business transaction and the block height of a block where the deposit business transaction is located are recorded by the precompiled contract; for another example, when executing the withdrawal service, the extraction of n coins in the withdrawal service transaction and the block height of the block where the withdrawal service transaction is located are recorded by a pre-compiled contract.
Based on the log management system, the embodiment of the invention provides a log query scheme, which queries log data required by a user by calling a pre-compiled contract through a log management contract, so as to realize more convenient log query. Specifically, the log query scheme may include: receiving a log query request, acquiring a log management contract according to a first address of a log management contract included in the log query request, and calling a precompiled contract according to a second address of the precompiled contract by running the log management contract to acquire target log data requested by the log query request.
Based on the above description, an embodiment of the present invention provides a log query method, and a flowchart of the log query method is provided for an embodiment of the present invention with reference to fig. 3. The log query method shown in fig. 3 can be applied to a blockchain, and is executed by a node device in the blockchain. The log query method may include the steps of:
step S301, receiving a log query request, wherein the log query request comprises a first address of a log management contract in a block chain and an identifier of target log data requested to be queried.
The log query request may be issued by a target external account to the blockchain, where the target external account may refer to any one external account of the blockchain. As can be seen from the foregoing, the second address of the precompiled contract is not disclosed to the outside, and in order to enable the external account to successfully invoke the precompiled contract, the developer also develops a corresponding log management contract for the precompiled contract, where the log management contract includes the second address of the precompiled contract, and displays the first address of the log management contract to the external account, and the external account may send a request to the first address to start the log management contract. When the log management contract is run, the precompiled contract is automatically invoked according to the second address.
Therefore, if the target account wants to query the target log data through the precompiled contract, the log management contract needs to be started, so that the first address of the log management contract needs to be carried in the log query request when the target account sends the log query request.
In one embodiment, when a developer writes a log management contract, the developer may provide an external interface (Ilogger), where the external interface may provide a series of log recording methods and/or log query methods, and parameters corresponding to the various methods, and the log management contract may know, through the external interface, the log recording method or the log query method included in the log management contract, and which parameters are required under the corresponding methods, so that the target account may be seen, so that the target account may know the methods provided by the log management system. When the target account sends the log query request, the log query method corresponding to the target log and the parameters required by the log query method can be carried in the log query request, so that the log management contract calls the precompiled contract to obtain the target log data by adopting the corresponding log query method. Assuming that the first address is 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c, when the target account sends the log query request, the variable ILogger log can be carried in the log query request, and the pre-compiling contract can be called by the log management contract to obtain the target log data. Alternatively, the ILogger log variable may be represented by a sub-formula as follows:
ILogger log=logger(address(0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c))
in one embodiment, in order to prevent malicious accounts from constantly flushing logs in a blockchain, wasting storage space, the log management contract may further perform a setup interface that provides account blacklists and whitelists. In a specific implementation, a manager can determine which accounts are blacklisted accounts and which accounts are white-listed accounts through a setting interface provided by a log management contract; the log management contract may not run when it is detected that the blacklisted account sent a log query request or other business transaction to the first address.
In one embodiment, the log recording method and the log query method are corresponding, and colloquially, by what method the stored log data needs to be queried using a matching method. The log recording method and the log query method are corresponding to each other, which means that the log recording method and the log query method are the same; or, the correspondence between the log recording method and the log query method may also mean that a mapping relationship exists between the log recording method and the log query method. For convenience of description, in the following description of the embodiments of the present invention, a logging method is the same as the log query method.
In one embodiment, log data in a blockchain can be broadly divided into three types: vital log data, general error log data, and vital error log data. The log data generated by different types of business transactions are defined differently for the three types of log data. For example, for the transfer business transaction, important log data can refer to transfer running, common error log data can refer to account balance shortage of a transfer party during transfer, and the like; for the authorization service transaction, the important log data may refer to authorized log data, or log data for removing the right, and so on, which are not listed in the embodiment of the present invention.
In one embodiment, the log query method for each type of log data is different. For example, the log query method corresponding to the important log data may be: an identifier (fluid errorCode, string msg), where the errorCode represents an identifier of log data, and may also be referred to as a code of the log data, and is used to uniquely represent the log data, and the string represents that the log data is stored in a plaintext form; the log query method corresponding to the common Error log data may be Error (string msg); the log query method corresponding to the significant error log data may be a total (string msg). Optionally, in a scenario that log data is stored in a plaintext form, if the log data is stored in a non-plaintext form, the log query method corresponding to the Important log may be inportant (user error code, bytes msg), and bytes indicates that the log data is stored in a non-plaintext form; the log query method corresponding to the common error log data may be: error (uint errorCode, bytes msg); the log query method corresponding to the major error log data may be: fotal (uint errorCode, bytes msg).
Based on the above description, the log query request sent by the target account may further include a log data type and a first log query method corresponding to the log data type, where the log data type is used to indicate which type of log data the target account wants to query, and the log data type includes any one of the three types, for example, the log data type may be important log data, common error log data, and the like. The first log query method is a log query method corresponding to the log data type, and if the log data type is Important log data, the first log query method is a log query method corresponding to the Important log data, and may be, for example, an inportant (string msg) or an inportant (byte msg) described above.
In one embodiment, the target account may select which log data to store in the clear according to its own needs, and which log data to store in the non-clear (also referred to as binary storage). When storing the non-plaintext data, the log data may be encrypted by using the public key corresponding to the target account to obtain the non-plaintext binary data. The binary number can be decrypted through a private key corresponding to the target account to obtain the log data of the plaintext.
In one embodiment, the log query request may be generated when a log query service contract issued by the target account is run. Optionally, the target account may write a log query service contract in advance, and issue the log query service contract into the block chain, where the log query service contract is used to indicate that execution of the log query service contract is triggered to generate the log query request when the target account is detected to send the log query transaction. Optionally, the log query transaction issued by the user carries the first address of the log management contract and the identifier of the target log data. And generating a log query request according to the first address of the log management contract and the identification of the log data at the running time by the log query service contract.
Step S302, a log management contract is obtained according to the first address, the log management contract including a second address of the precompiled contract.
As can be seen from the foregoing, the intelligent contracts in the blockchain are stored in the contract accounts, and therefore, the first address of the log management contract in step S302 refers to the address of the contract account storing the log management contract. In one embodiment, in step S301, sending, by the target account, the log query request carrying the first address may actually be understood that the target account sends the log query request to the contract account corresponding to the first address, and after receiving the log query request, the node device obtains, from the database, a code in the contract account corresponding to the first address, that is, obtains the log management contract.
And step S303, calling a precompiled contract according to the second address by running a log management contract to acquire target log data corresponding to the target log data identifier from a preset storage position.
As can be seen from the foregoing, the intelligent contract is executed based on the EVM interpreter in the blockchain, so that after the code in the contract account of the first address is acquired, the code is transferred to the EVM interpreter for running. The method includes the steps that the contracts and the contracts can be called in a block chain, and the precompiled contracts are called by using the second address along with running of the log management contracts, and then the precompiled contracts start to run.
In an embodiment, the target account described in the embodiment of the present invention may be an individual account or an administrator account, and for security of log query, query authority of each account may be set. For example, for an individual account, only log data generated by the account in an ether house can be queried, and log data of other accounts cannot be queried; for an administrator account, log data pertaining to an account managed by the administrator account may be queried. Therefore, if the target account is an individual account, the target log data requested to be queried by the log query request in step S301 may be generated by the target business transaction issued by the target account in the blockchain; if the target account is the administrator account, the target log data requested to be queried by the log query request in step S301 may be generated by a business transaction issued in the blockchain by any one or more accounts of the accounts managed by the administrator account. For convenience of description, the following description refers to the target account, and the target account is taken as an individual account as an example.
As can be seen from the foregoing, the target log data requested to be queried by the target account is generated by the target business transaction issued into the blockchain by the target account before, and the precompiled contract is called by the log management contract and stored in the preset location. The preset location may be set by a developer when the developer writes a precompiled contract and may be modified by the developer, and the preset storage location may be in a file system or a database.
In one embodiment, the obtaining, by running a log management contract and calling a precompiled contract according to the second address, target log data corresponding to a target log data identifier from a preset storage location includes: acquiring all log data which can be inquired by a target account according to the log inquiry authority of the target account; and finding the target log data corresponding to the identification of the target log data from all the queryable log data.
In the embodiment of the invention, after a log query request is received, a log management contract is obtained according to a first address of the log management contract included in the log query request, the log management contract includes a second address of a precompiled contract, and the precompiled contract is used for transmitting log data generated by business transaction in the block chain from the log management contract to a preset storage position for storage; and then, calling the pre-compiling contract according to the second address by running the log management contract to acquire target log data corresponding to the identifier of the target log data from the preset storage position. In addition, the precompiled contract runs outside the EVM of the virtual machine and runs depending on the EVM, so that the speed of calling the precompiled contract to obtain the target log through the log management contract is higher, and the log can be inquired quickly.
Based on the above embodiment of the log query method, an embodiment of the present invention provides another log query method, and fig. 4 is a schematic flow chart of another log query method provided by an embodiment of the present invention. The log query method shown in fig. 4 can be applied to a blockchain, and is executed by a node device in the blockchain. The log query method can comprise the following steps:
step S401, receiving a log storage request, wherein the log query request comprises a target service transaction, log storage indication information and a first address of a log management contract.
The target business transaction can be any business transaction issued by the target account to the blockchain, such as a transfer transaction, a contract creation transaction or an authorization transaction. The log storage request can comprise a target service transaction, log storage indication information and a first address of a log management contract, and is used for indicating that target log data corresponding to the storage indication information in service log data generated in the target service transaction executing process are stored to a preset position in a mode of calling a pre-compiling contract through the log management contract.
The storage indication information may include a log data category and a log recording method corresponding to the log data category. In one embodiment, the target business transaction may include at least one sub-transaction, each sub-transaction being executed to generate log data corresponding to the sub-transaction, and the business log data generated during the execution of the target business transaction is composed of the log data generated when each sub-transaction is executed. The target log data corresponding to the storage indication information may be service log data generated by a target service transaction, wherein the log data type is the same as the log data type indicated by the storage indication information. In other words, the service log data of the same type as the log data indicated by the storage indication information in the service log data corresponding to the target service transaction is taken as the target log data.
In one embodiment, the log storage request may be issued by the target account into the blockchain, and as can be seen from the foregoing, the log storage request in the target account sending step S401 is to send target log data generated by the target business transaction to the precompiled contract through the log management contract, and then invoke the precompiled contract to store the received log data in the preset location. Based on this, if the target account wants to store the target service transaction in the above manner, it needs to issue a log storage request as shown in step S401 when the target service transaction is initiated to the blockchain; if the target account does not simultaneously initiate the log storage request when initiating the target service transaction, the target log data generated by the target service transaction may be stored to the default position of the blockchain by means of EVM encryption. Based on the above, the target user can select the storage mode of the service log data generated by the target service transaction by the mode of whether to initiate the log storage request or not when the target service transaction is issued, so that the log data storage mode is enriched, and the user experience is improved.
In other embodiments, the log storage request may also be generated when a log storage service contract written by the target account is run. It should be appreciated that if the target account wants to store the business transaction data generated by its corresponding target business transaction by calling the precompiled contract through the log management contract, for convenience of user operation, the target account may pre-compile a log storage service contract, the log storage service contract includes a first address of a log management contract, the log storage service contract specifying that when a target account is detected to initiate a target service transaction at the blockchain, the log storage service contract is activated, a log storage request carrying storage indication information is generated, and invoking log management contract according to the first address, the log management contract acquiring target log data corresponding to the storage indication information in the target service transaction, and calling the precompiled contract according to the second address, sending the target log data to the precompiled contract, operating the precompiled contract and storing the received target log data to a preset storage position. In this way, when the target account sends the target service transaction each time, the storage indication information and the target service transaction are issued to the blockchain, so that the operation of the target account in log storage is simplified.
Step S402, obtaining a log management contract according to the first address, wherein the log management contract comprises a second address of the precompiled contract.
Step S403, obtaining target log data generated by the target service transaction by running a log management contract, and calling a precompiled contract according to the second address to receive the target log data.
And step S404, running the precompiled contract to store the target log data to a preset storage position.
In one embodiment, when the log management precompiled contract is run to store the target log data to the preset storage position, the associated information of the target log data can be obtained; then, the pre-compiling contract is called by the log management contract according to the second address to store the target log data and the associated information in the preset storage position in an associated manner, so that the target log data can be subjected to statistical analysis subsequently according to the associated information of the target log data, for example, all log data of a target account are counted, log data corresponding to business transactions included in a block with a certain block height are counted, and the like.
In one embodiment, if the log storage request is generated at the time of running the log storage service contract, the associated information of the target log data includes one or more of: the identification of the target service transaction, the block height of a block where the target service transaction is located, a third address of the log storage service contract and the identification of the target account;
in other embodiments, if the log storage request is that the target account is published into a blockchain, the associated information of the target log data includes one or more of: the identification of the target business transaction, the block height of the block where the target business transaction is located and the identification of the target account.
In one embodiment, to prevent over consumption of the log, certain storage resources are charged according to the size of the target log data when the target log data in the precompiled contract memory block chain is called. As can be seen from the foregoing, each transaction submitted to the blockchain by each account includes a resource upper limit (the resource upper limit is the most resource that the account is willing to pay for the transaction), so that the target transaction sent by the target account includes a target resource upper limit (the target resource upper limit can be understood as a pre-stored transaction resource for the target account to execute the target transaction), and as can be seen from the foregoing, the target transaction includes at least one sub-transaction, each sub-transaction consumes the pre-stored transaction resource corresponding to the target transaction when executed, and each sub-transaction generates corresponding log data when executed, and also consumes the pre-stored transaction resource when storing the log data corresponding to each sub-transaction. Assuming that the target sub-transaction is included in the at least one sub-transaction, the target log data is generated when the target sub-transaction is executed.
Therefore, when the target log data generated by the target service transaction is stored, whether the target log data can be successfully stored is determined according to the storage resource required by the target log data, the pre-stored transaction resource of the target service transaction and the unused resource in the pre-stored transaction resource. In a specific implementation, the invoking, by the log management contract according to the second address, the precompiled contract to obtain target log data, and storing the target log data in the preset storage location includes: acquiring the size of the target log data generated by the target service transaction, and acquiring storage resources required for storing the target log data and execution resources required for executing sub-transactions generating the target log data in the target service transaction according to the size of the target log data; and when detecting that the sum of the storage resource and the execution resource is not more than the unused transaction resource in the pre-stored transaction resources, executing the step of calling the pre-compiling contract according to the second address through the log management contract to acquire target log data included in service log data generated by the target service transaction, and storing the target log data to the preset storage position.
On the contrary, when it is detected that the sum of the storage resource and the execution resource is greater than the unused transaction resource in the pre-stored transaction resource, the step of calling the pre-compiled contract according to the second address by the log management contract to obtain the target log data included in the service log data generated by the target service transaction and storing the target log data in the preset storage location may not be executed. Meanwhile, prompt information of the target sub-transaction execution failure can be output to prompt the target account that the target sub-transaction fails.
For example, assume that the target business transaction is a transfer transaction, the target business transaction includes 5 pre-stored transaction resources, and the target business transaction includes two sub-transactions, where the first sub-transaction is a transfer of X to account a, the second sub-transaction is a transfer of Y to account B, and the second sub-transaction is assumed to be a target sub-transaction. Assuming that when the first sub-transaction is executed, the execution resource required for transferring accounts to the account A is calculated to be 1, the storage resource required for storing first log data generated by the first sub-transaction is calculated to be 2, and when the sum of the execution resource and the storage resource is judged to be smaller than the pre-stored transaction resource of the target business machine transaction when the first sub-transaction is executed, and the first log data generated by the first sub-transaction is stored. At this time, the unused transaction resource in the pre-stored transaction resource is 2, further, the execution resource required when the target sub-transaction is executed is calculated to be 2, the storage resource required when the target log data generated by the target sub-transaction is stored is 2, and at this time, the sum of the execution resource and the storage resource when the target sub-transaction is executed is greater than the unused transaction resource, the target sub-transaction is executed unsuccessfully, and the target log data cannot be stored.
Step S405, receiving a log query request, wherein the log query request comprises a first address of a log management contract and an identifier of target log data requested to be queried.
Step S406, obtaining a log management contract according to the first address, and calling a precompiled contract according to the second address through the log management contract to obtain target log data corresponding to the identifier of the target log data from a preset storage position.
Some possible implementations related to steps S405 and S406 may refer to descriptions of related steps in the embodiment of fig. 2, and are not described herein again.
In one embodiment, the precompiled contract may receive and store exception information and exception times of node devices in the blockchain in addition to log data generated by business transactions of the account. Specifically, when detecting that the node device in the block chain is abnormal, obtaining abnormal information of the node device; and running the log management contract to call the precompiled contract according to the second address to store the abnormal information of the node equipment and the times of the abnormal occurrence of the node equipment to the preset storage position. The preset storage positions for storing the abnormal information and the abnormal times of the node device may be the same as or different from the preset storage positions for storing log data generated by the service transaction of the account.
The node device refers to any node device in the block chain, and the abnormal information of the node device may include frequent online and offline of the node device, inconsistency between data reported by the node device and data reported by other node devices, and the like.
In one embodiment, a node device management contract may be written to detect exception information for each node device in the blockchain. When monitoring that a certain node device is abnormal, acquiring abnormal information of the node device, and storing the abnormal information of the node device and the abnormal times of the node device by calling a pre-compiled contract.
In one embodiment, when an alarm event is detected to occur in a blockchain, an alarm notification is sent out; wherein the alarm event comprises one or more of: the number of service contracts issued by the target account in first preset time exceeds a first threshold, the number of service log data generated by the log storage service contracts in second preset time is greater than a second threshold, and the number of times of abnormity of the node equipment exceeds a third threshold. The business contracts issued by the target account may include any contract, such as log store business contracts, log query business contracts, and the like.
In one embodiment, the block chain may store japanese data of the business transaction and abnormal information of the node device through a pre-compiling contract, so that all log data of the block chain may be counted and analyzed to determine whether to store the alarm event in cooperation with a common log analysis tool. If the preset storage position specified in the precompiled contract is a file, log data of the whole block chain can be analyzed and monitored by using log analysis tools Nagios, elastic stack and the like in a matching manner; if the preset storage position specified in the precompiled contract is a database, some functions of the database can be taken to analyze the log data on the blockchain.
In one embodiment, the log data of the block chain can also be subjected to timed archiving processing through the log data stored by the precompiled contract, such as setting to transfer the log data stored for a long time from one storage position to another storage position; or, archive some type of log data to the same storage location, and so on.
In the embodiment of the invention, after a log storage request sent by a target account is received, a log management contract is obtained according to a first address in the log storage request, a precompiled contract is called according to a second address in the log management contract by running the log management contract to obtain target log data generated by target service transaction, and the target log data is stored to a preset storage position, wherein the target log data is service log data corresponding to target storage indication information in the service log data generated by the target service transaction. Further, when a log query request is received, a log management contract is obtained according to a first address in the log query request, and target log data is obtained from a preset storage position by calling a precompiled contract according to a second address through running the log management contract. In the log query process, the convenience of log recording or query can be improved by calling pre-compiled contract records or query logs through log management contracts. In addition, the precompiled contract runs outside the virtual machine EVM of the block chain, and the running speed is high, so that the speed is high when the precompiled contract is called to store log data and inquire the log data. In addition, when the log data is stored through the pre-compiled contract, the target account can select to store the log data in a plaintext form or a non-plaintext form according to the requirement of the target account, so that the log storage form is enriched.
Based on the description of the above method embodiment, an embodiment of the present invention provides a log query apparatus, and referring to fig. 5, a schematic structural diagram of the log query apparatus provided in the embodiment of the present invention is shown. The following units can be operated in the log query device shown in fig. 5:
a receiving unit 501, configured to receive a log query request, where the log query request includes a first address of a log management contract in a blockchain and an identifier of target log data requested to be invoked;
an obtaining unit 502, configured to obtain the log management contract according to the first address, where the log management contract includes a second address of a precompiled contract, and the precompiled contract is used to transmit log data generated by a service transaction in the block chain from the log management contract to a preset storage location for storage;
the processing unit 503 is further configured to invoke the precompiled contract according to the second address by running the log management contract, and obtain the target log data corresponding to the identifier of the target log data from the preset storage location.
In one embodiment, the receiving unit 501 is further configured to receive a log storage request, where the log storage request includes a target business transaction, log storage indication information, and the first address of the log management contract; the obtaining unit 502 is further configured to obtain the log management contract according to the first address, where the log management contract includes a second address of a precompiled contract; the processing unit 503 is further configured to obtain target log data generated by the target service transaction by running the log management contract, call the precompiled contract according to the second address to receive the target log data, and store the target log data in the preset storage location, where the target log data is service log data corresponding to the log storage indication information in the service log data generated by the target service transaction.
In one embodiment, the log storage request is generated when a log storage service contract is run, the log storage service contract is issued to the block chain by a target account, and the log storage service contract is used for indicating that when the target service transaction initiated by the target account is detected, log storage indication information corresponding to the target service transaction is acquired, and a log storage request carrying the log storage indication information is initiated. The processing unit 503 is further configured to invoke, by the log management contract according to the second address, the precompiled contract to obtain associated information associated with the target log data, where the associated information includes one or more of: the identification of the target service transaction, the block height of a block where the target service transaction is located, a third address of the log storage service contract and the identification of the target account; the processing unit 503 is further configured to invoke the precompiled contract to store the target log data and the associated information in the preset storage location in an associated manner.
In one embodiment, the target business transaction comprises at least one sub-transaction, and the business log data generated by the target business transaction is composed of the business log data generated by the at least one sub-transaction; the target service transaction includes a pre-stored transaction resource, the pre-stored transaction resource is consumed when the at least one sub-transaction is run, and the processing unit 503 executes the following operations when invoking the pre-compiled contract according to the second address to receive the target log data and storing the target log data in the preset storage location: acquiring the size of the target log data generated by the target service transaction, and acquiring storage resources required for storing the target log data and execution resources required for executing sub-transactions generating the target log data in the target service transaction according to the size of the target log data; and when detecting that the sum of the storage resource and the execution resource is not more than the unused trading resource in the pre-stored trading resources, executing the step of calling the pre-compilation contract according to the second address to receive the target log data and storing the target log data to the preset storage position.
In one embodiment, the obtaining unit 502 is further configured to obtain, when detecting that a node device in the blockchain is abnormal, abnormal information of the node device; the processing unit 503 is further configured to run the log management contract to invoke the precompiled contract according to the second address to store the exception information of the node device and the number of times that the node device has an exception to the preset storage location.
In one embodiment, the processing unit 503 is further configured to issue an alarm notification when an alarm event is detected to occur; wherein the alarm event comprises one or more of: the number of service contracts issued by the target account in first preset time exceeds a first threshold, the number of service log data generated by the log storage service contracts in second preset time is greater than a second threshold, and the number of times of abnormity of the node equipment exceeds a third threshold.
In an embodiment, the log query request further includes a log data type and a first log query method corresponding to the log data type, the log management contract includes a second log query method corresponding to the log data type, and the log query apparatus further includes a determining unit 504, configured to determine whether the first log query method and the second log query method match; the processing unit 503 is configured to execute the step of obtaining the target log data corresponding to the identifier of the target log data from the preset storage location by invoking the precompiled contract according to the second address by running the log management contract if the first log query method and the second log query method match.
According to an embodiment of the present invention, the steps involved in the log query methods shown in fig. 3 and fig. 4 may be performed by the units in the log query processing apparatus shown in fig. 5. For example, step S301 shown in fig. 3 may be executed by the receiving unit 501 in the log query device shown in fig. 5, step S302 may be executed by the obtaining unit 502 in the log query device shown in fig. 5, and step S203 may be executed by the processing unit 503 in the log query device shown in fig. 5; as another example, steps S401 and S405 shown in fig. 4 may be performed by the receiving unit 501 in the log querying device shown in fig. 5, steps S402 and S406 may be performed by the obtaining unit 502 in the log querying device shown in fig. 5, and steps S403 and S406 may be performed by the processing unit 503 in the log querying device shown in fig. 5.
According to another embodiment of the present invention, the units in the log query apparatus shown in fig. 5 may be respectively or entirely combined into one or several other units to form the log query apparatus, or some unit(s) thereof may be further split into multiple units with smaller functions to form the log query apparatus, which may achieve the same operation without affecting the achievement of the technical effect of the embodiment of the present invention. The units are divided based on logic functions, and in practical application, the functions of one unit can be realized by a plurality of units, or the functions of a plurality of units can be realized by one unit. In other embodiments of the present invention, the log query device may also include other units, and in practical applications, these functions may also be implemented by being assisted by other units, and may be implemented by cooperation of multiple units.
According to another embodiment of the present invention, the log query apparatus as shown in fig. 5 may be constructed by running a computer program (including program codes) capable of executing the steps involved in the corresponding method as shown in fig. 3 or fig. 4 on a general-purpose computing device such as a computer including a Central Processing Unit (CPU), a random access storage medium (RAM), a read-only storage medium (ROM), and the like, and a storage element, and the log query method according to an embodiment of the present invention may be implemented. The computer program may be embodied on a computer-readable storage medium, for example, and loaded into and executed by the above-described computing apparatus via the computer-readable storage medium.
In the embodiment of the invention, after a log query request is received, a log management contract is obtained according to a first address of the log management contract included in the log query request, the log management contract includes a second address of a precompiled contract, and the precompiled contract is used for transmitting log data generated by business transaction in the block chain from the log management contract to a preset storage position for storage; and then, calling the pre-compiling contract according to the second address by running the log management contract to acquire target log data corresponding to the identifier of the target log data from the preset storage position. In addition, the precompiled contract runs outside the EVM of the virtual machine and runs depending on the EVM, so that the speed of calling the precompiled contract to obtain the target log through the log management contract is higher, and the log can be inquired quickly.
Based on the description of the foregoing embodiment and the apparatus embodiment, an embodiment of the present invention further provides a node device, where the node device may be any one of node devices in a block chain. Fig. 6 is a schematic structural diagram of a node device according to an embodiment of the present invention. As shown in fig. 6, the node device includes at least a processor 601, an input interface 602, an output interface 603, and a computer storage medium 604. The processor 601, the input interface 602, the output interface 603, and the computer storage medium 604 in the node device may be connected by a bus or other means.
A computer storage medium 604 may be stored in the memory of the node device, said computer storage medium 604 being adapted to store a computer program comprising program instructions, said processor 601 being adapted to execute the program instructions stored by said computer storage medium 604. The processor 801 (or CPU) is a computing core and a control core of the node device, and is adapted to implement one or more instructions, and specifically, adapted to load and execute the one or more instructions so as to implement a corresponding method flow or a corresponding function; in one embodiment, the processor 601 according to an embodiment of the present invention may be configured to perform: receiving a log query request, wherein the log query request comprises a first address of a log management contract in a block chain and an identifier of target log data requested to be called; acquiring the log management contract according to the first address, wherein the log management contract comprises a second address of a precompiled contract, and the precompiled contract is used for transmitting log data generated by business transactions in the block chain from the log management contract to a preset storage position for storage; and calling the pre-compiling contract according to the second address by running the log management contract to acquire the target log data corresponding to the identifier of the target log data from the preset storage position.
An embodiment of the present invention further provides a computer storage medium (Memory), which is a Memory device in the node device and is used to store programs and data. It is understood that the computer storage medium herein may include both a built-in storage medium in the node device and, of course, an extended storage medium supported by the node device. The computer storage medium provides a storage space that stores an operating system of the node device. Also stored in this memory space are one or more instructions, which may be one or more computer programs (including program code), suitable for loading and execution by processor 601. The computer storage medium may be a high-speed RAM memory, or may be a non-volatile memory (non-volatile memory), such as at least one disk memory; and optionally at least one computer storage medium located remotely from the processor.
In one embodiment, one or more instructions stored in a computer storage medium may be loaded and executed by processor 601 to implement the corresponding steps of the method described above in relation to the log query method embodiment; in particular implementations, one or more instructions in the computer storage medium are loaded and executed by processor 601 to perform the steps of: in one embodiment, one or more instructions stored in a computer storage medium may be loaded and executed by processor 601 to perform the corresponding steps described above with respect to the method in the service update embodiment; in particular implementations, one or more instructions in the computer storage medium are loaded and executed by processor 601 to perform the steps of: receiving a log query request, wherein the log query request comprises a first address of a log management contract in a block chain and an identifier of target log data requested to be called; acquiring the log management contract according to the first address, wherein the log management contract comprises a second address of a precompiled contract, and the precompiled contract is used for transmitting log data generated by business transactions in the block chain from the log management contract to a preset storage position for storage; and calling the pre-compiling contract according to the second address by running the log management contract to acquire the target log data corresponding to the identifier of the target log data from the preset storage position.
In one embodiment, the processor 601 further performs: receiving a log storage request, the log storage request including a target business transaction, log storage indication information, and the first address of the log management contract; obtaining the log management contract according to the first address, the log management contract comprising a second address of a precompiled contract; and acquiring target log data generated by the target service transaction by operating the log management contract, calling the precompiled contract according to the second address to receive the target log data, and storing the target log data to the preset storage position, wherein the target log data is service log data corresponding to the log storage indication information in the service log data generated by the target service transaction.
In one embodiment, the log storage request is generated when a log storage service contract is executed, where the log storage service contract is issued by a target account into the block chain, and the log storage service contract is used to indicate that, when the target service transaction initiated by the target account is detected, log storage indication information corresponding to the target service transaction is acquired, and a log storage request carrying the log storage indication information is initiated, where the processor 601 further executes: invoking, by the log management contract according to the second address, the precompiled contract to obtain associated information associated with the target log data, the associated information including one or more of: the identification of the target service transaction, the block height of a block where the target service transaction is located, a third address of the log storage service contract and the identification of the target account; and calling the precompiled contract to store the target log data and the associated information in the preset storage position in an associated manner.
In one embodiment, the target business transaction comprises at least one sub-transaction, and the business log data generated by the target business transaction is composed of the business log data generated by the at least one sub-transaction; the target service transaction includes a pre-stored transaction resource, the pre-stored transaction resource is consumed when the at least one sub-transaction is run, and the processor 601 executes the following operations when invoking the pre-compiled contract according to the second address to receive the target log data and storing the target log data to the preset storage position: acquiring the size of the target log data generated by the target service transaction, and acquiring storage resources required for storing the target log data and execution resources required for executing sub-transactions generating the target log data in the target service transaction according to the size of the target log data; and when detecting that the sum of the storage resource and the execution resource is not more than the unused trading resource in the pre-stored trading resources, executing the step of calling the pre-compilation contract according to the second address to receive the target log data and storing the target log data to the preset storage position.
In one embodiment, the processor 601 is further configured to: when detecting that the node equipment in the block chain is abnormal, acquiring abnormal information of the node equipment; and running the log management contract to call the precompiled contract according to the second address to store the abnormal information of the node equipment and the times of the abnormal occurrence of the node equipment to the preset storage position.
In one embodiment, the processor 601 is further configured to: when detecting the occurrence of an alarm event, sending an alarm notification; wherein the alarm event comprises one or more of: the number of service contracts issued by the target account in first preset time exceeds a first threshold, the number of service log data generated by the log storage service contracts in second preset time is greater than a second threshold, and the number of times of abnormity of the node equipment exceeds a third threshold.
In one embodiment, the log query request further includes a log data type and a first log query method corresponding to the log data type, the log management contract includes a second log query method corresponding to the log data type, and the processor 601 is further configured to: judging whether the first log query method and the second log query method are matched; and if so, executing the step of obtaining the target log data corresponding to the identifier of the target log data from the preset storage position by operating the log management contract and calling the pre-compiling contract according to the second address.
In the embodiment of the invention, after a log query request is received, a log management contract is obtained according to a first address of the log management contract included in the log query request, the log management contract includes a second address of a precompiled contract, and the precompiled contract is used for transmitting log data generated by business transaction in the block chain from the log management contract to a preset storage position for storage; and then, calling the pre-compiling contract according to the second address by running the log management contract to acquire target log data corresponding to the identifier of the target log data from the preset storage position. In addition, the precompiled contract runs outside the EVM of the virtual machine and runs depending on the EVM, so that the speed of calling the precompiled contract to obtain the target log through the log management contract is higher, and the log can be inquired quickly.
The above disclosure is intended to be illustrative of only some embodiments of the invention, and is not intended to limit the scope of the invention.

Claims (10)

1. A log query method, comprising:
receiving a log query request, wherein the log query request comprises a first address of a log management contract in a block chain and an identifier of target log data requested to be called;
acquiring the log management contract according to the first address, wherein the log management contract comprises a second address of a precompiled contract, and the precompiled contract is used for transmitting log data generated by business transactions in the block chain from the log management contract to a preset storage position for storage;
and calling the pre-compiling contract according to the second address by running the log management contract to acquire the target log data corresponding to the identifier of the target log data from the preset storage position.
2. The method of claim 1, wherein prior to receiving the log query request, the method further comprises:
receiving a log storage request, the log storage request including a target business transaction, log storage indication information, and the first address of the log management contract;
obtaining the log management contract according to the first address, the log management contract comprising a second address of a precompiled contract;
and acquiring target log data generated by the target service transaction by operating the log management contract, calling the precompiled contract according to the second address to receive the target log data, and storing the target log data to the preset storage position, wherein the target log data is service log data corresponding to the log storage indication information in the service log data generated by the target service transaction.
3. The method of claim 2, wherein the log storage request is generated when a log storage service contract is executed, the log storage service contract is issued by a target account into the blockchain, the log storage service contract is used for indicating that when the target service transaction initiated by the target account is detected, log storage indication information corresponding to the target service transaction is acquired, and a log storage request carrying the log storage indication information is initiated, the method further comprising:
invoking, by the log management contract according to the second address, the precompiled contract to obtain associated information associated with the target log data, the associated information including one or more of: the identification of the target service transaction, the block height of a block where the target service transaction is located, a third address of the log storage service contract and the identification of the target account;
and calling the precompiled contract to store the target log data and the associated information in the preset storage position in an associated manner.
4. The method of claim 2, wherein the target business transaction comprises at least one sub-transaction, the business log data generated by the target business transaction consisting of the business log data generated by the at least one sub-transaction; the target service transaction comprises pre-stored transaction resources, the pre-stored transaction resources are consumed when the at least one sub-transaction is operated, the pre-compiled contract is called according to the second address to receive the target log data, and the target log data are stored in the preset storage position, and the method comprises the following steps:
acquiring the size of the target log data generated by the target service transaction, and acquiring storage resources required for storing the target log data and execution resources required for executing sub-transactions generating the target log data in the target service transaction according to the size of the target log data;
and when detecting that the sum of the storage resource and the execution resource is not more than the unused trading resource in the pre-stored trading resources, executing the step of calling the pre-compilation contract according to the second address to receive the target log data and storing the target log data to the preset storage position.
5. The method of claim 3, wherein the method further comprises:
when detecting that the node equipment in the block chain is abnormal, acquiring abnormal information of the node equipment;
and running the log management contract to call the precompiled contract according to the second address to store the abnormal information of the node equipment and the times of the abnormal occurrence of the node equipment to the preset storage position.
6. The method of claim 5, wherein the method further comprises:
when detecting the occurrence of an alarm event, sending an alarm notification;
wherein the alarm event comprises one or more of: the number of service contracts issued by the target account in first preset time exceeds a first threshold, the number of service log data generated by the log storage service contracts in second preset time is greater than a second threshold, and the number of times of abnormity of the node equipment exceeds a third threshold.
7. The method of claim 1, wherein the log query request further includes a log data type and a first log query method corresponding to the log data type, wherein the log management contract includes a second log query method corresponding to the log data type, and wherein before the target log data corresponding to the identifier of the target log data is obtained from the preset storage location by executing the log management contract to call the precompiled contract according to the second address, the method further comprises:
judging whether the first log query method and the second log query method are matched;
and if so, executing the step of obtaining the target log data corresponding to the identifier of the target log data from the preset storage position by operating the log management contract and calling the pre-compiling contract according to the second address.
8. A log querying device, comprising:
the device comprises a receiving unit, a sending unit and a receiving unit, wherein the receiving unit is used for receiving a log query request which comprises a first address of a log management contract in a block chain and an identifier of target log data requested to be called;
an obtaining unit, configured to obtain the log management contract according to the first address, where the log management contract includes a second address of a precompiled contract, and the precompiled contract is used to transmit log data generated by a service transaction in the block chain from the log management contract to a preset storage location for storage;
the obtaining unit is further configured to call the precompiled contract according to the second address by running the log management contract to obtain the target log data corresponding to the identifier of the target log data from the preset storage location.
9. A node apparatus, comprising:
a processor adapted to implement one or more instructions; and the number of the first and second groups,
a computer storage medium storing one or more instructions adapted to be loaded by the processor and to perform the log query method of any of claims 1-7.
10. A computer storage medium having computer program instructions stored therein, which when executed by a processor, is configured to perform the log query method of any one of claims 1 to 7.
CN201911151996.5A 2019-11-21 2019-11-21 Log query method and device, node equipment and storage medium Active CN111061685B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911151996.5A CN111061685B (en) 2019-11-21 2019-11-21 Log query method and device, node equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911151996.5A CN111061685B (en) 2019-11-21 2019-11-21 Log query method and device, node equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111061685A true CN111061685A (en) 2020-04-24
CN111061685B CN111061685B (en) 2022-07-22

Family

ID=70298302

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911151996.5A Active CN111061685B (en) 2019-11-21 2019-11-21 Log query method and device, node equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111061685B (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111488388A (en) * 2020-05-27 2020-08-04 支付宝(杭州)信息技术有限公司 Method, device and equipment for deploying data storage contract
CN113268464A (en) * 2021-06-07 2021-08-17 平安科技(深圳)有限公司 Log display method and device, electronic equipment and storage medium
CN113347033A (en) * 2021-05-31 2021-09-03 中国工商银行股份有限公司 Root cause positioning method and system based on block chain and verification node
CN113805889A (en) * 2021-08-27 2021-12-17 成都质数斯达克科技有限公司 Intelligent contract calling execution method, device, equipment and readable storage medium
CN114116774A (en) * 2022-01-28 2022-03-01 北京安帝科技有限公司 Log data query method and device
CN114897532A (en) * 2022-07-11 2022-08-12 杭州趣链科技有限公司 Operation log processing method, system, device, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170230189A1 (en) * 2016-02-04 2017-08-10 Nasdaq Technology Ab Systems and methods for storing and sharing transactional data using a distributed computing systems
CN108509523A (en) * 2018-03-13 2018-09-07 深圳前海微众银行股份有限公司 Structuring processing method, equipment and the readable storage medium storing program for executing of block chain data
CN108833514A (en) * 2018-06-01 2018-11-16 众安信息技术服务有限公司 Audit log processing method, device and Log Audit System based on block chain
CN109559229A (en) * 2018-11-30 2019-04-02 众安信息技术服务有限公司 The method of the intelligent contract group of update based on block chain
CN110223172A (en) * 2019-05-20 2019-09-10 阿里巴巴集团控股有限公司 The receipt storage method and node of conditional combination code mark and type dimension

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170230189A1 (en) * 2016-02-04 2017-08-10 Nasdaq Technology Ab Systems and methods for storing and sharing transactional data using a distributed computing systems
CN108509523A (en) * 2018-03-13 2018-09-07 深圳前海微众银行股份有限公司 Structuring processing method, equipment and the readable storage medium storing program for executing of block chain data
CN108833514A (en) * 2018-06-01 2018-11-16 众安信息技术服务有限公司 Audit log processing method, device and Log Audit System based on block chain
CN109559229A (en) * 2018-11-30 2019-04-02 众安信息技术服务有限公司 The method of the intelligent contract group of update based on block chain
CN110223172A (en) * 2019-05-20 2019-09-10 阿里巴巴集团控股有限公司 The receipt storage method and node of conditional combination code mark and type dimension

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111488388A (en) * 2020-05-27 2020-08-04 支付宝(杭州)信息技术有限公司 Method, device and equipment for deploying data storage contract
CN111488388B (en) * 2020-05-27 2023-10-13 支付宝(杭州)信息技术有限公司 Deployment method, device and equipment of data storage contract
CN113347033A (en) * 2021-05-31 2021-09-03 中国工商银行股份有限公司 Root cause positioning method and system based on block chain and verification node
CN113268464A (en) * 2021-06-07 2021-08-17 平安科技(深圳)有限公司 Log display method and device, electronic equipment and storage medium
CN113268464B (en) * 2021-06-07 2023-06-23 平安科技(深圳)有限公司 Log display method and device, electronic equipment and storage medium
CN113805889A (en) * 2021-08-27 2021-12-17 成都质数斯达克科技有限公司 Intelligent contract calling execution method, device, equipment and readable storage medium
CN114116774A (en) * 2022-01-28 2022-03-01 北京安帝科技有限公司 Log data query method and device
CN114897532A (en) * 2022-07-11 2022-08-12 杭州趣链科技有限公司 Operation log processing method, system, device, equipment and storage medium

Also Published As

Publication number Publication date
CN111061685B (en) 2022-07-22

Similar Documents

Publication Publication Date Title
CN111061685B (en) Log query method and device, node equipment and storage medium
CN111543031B (en) Method and control system for controlling and/or monitoring a device
US7752463B2 (en) Automatically filling a drive table
CN109067528B (en) Password operation method, work key creation method, password service platform and equipment
CN110661658B (en) Node management method and device of block chain network and computer storage medium
US11025415B2 (en) Cryptographic operation method, method for creating working key, cryptographic service platform, and cryptographic service device
KR20160139493A (en) Method and apparatus for managing encryption keys for cloud service
CN101783801A (en) Software protection method based on network, client side and server
EP2862119B1 (en) Network based management of protected data sets
CN110289965B (en) Application program service management method and device
US20200167342A1 (en) System for Secure Software Defined Networking Based on Block-Chain and Method Thereof
US11928449B2 (en) Information processing method, device, apparatus and system, medium, andprogram
CN109697370A (en) Database data encipher-decipher method, device, computer equipment and storage medium
CN111492355A (en) Method and control system for controlling and/or monitoring a device
JP2017527140A (en) Routing method for transferring task instructions between computer systems, computer network infrastructure, and computer program
CN111597537B (en) Block chain network-based certificate issuing method, related equipment and medium
CN110602051B (en) Information processing method based on consensus protocol and related device
US20230244797A1 (en) Data processing method and apparatus, electronic device, and medium
CN112286911A (en) Database management method and device, equipment and storage medium
CN113922972B (en) Data forwarding method and device based on MD5 identification code
CN107085681B (en) Robust computing device identification framework
US20140366084A1 (en) Management system, management method, and non-transitory storage medium
CN110022310B (en) Authorization method and device based on cloud computing open network operating system
CN110597557A (en) System information acquisition method, terminal and medium
CN117527238B (en) Key generation method, device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40021487

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant