Data processing method and device of block chain network, product, equipment and medium

By dividing contract bytecode into on-chain and off-chain parts, the problem of limited contract event storage and modification is solved, thereby improving data processing methods, devices, products, equipment and media in blockchain networks. Specifically, this involves applications in data processing devices, products, equipment and media.

CN120980086APending Publication Date: 2025-11-18TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410612600.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-16
Publication Date
2025-11-18

AI Technical Summary

Technical Problem

In existing technologies, the storage and modification of contract events on the blockchain are limited, lacking flexibility and convenience.

Method used

The contract bytecode is divided into on-chain and off-chain parts. Event bytecode is filtered out. Contract events are stored in the off-chain part, which contains event bytecode. This is used to generate and store contract events.

Benefits of technology

It enhances the flexibility and convenience of storing and modifying contract events, avoids on-chain storage costs, and supports on-demand adjustments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120980086A_ABST
    Figure CN120980086A_ABST
Patent Text Reader

Abstract

The invention discloses a data processing method and device for a block chain network, a product, equipment and a medium, the method is applied to a first block chain node, and the method comprises the following steps: obtaining a smart contract needing to be deployed, and compiling the smart contract according to a data format adapted to the block chain network to generate a contract byte code of the smart contract; the contract byte code comprises an event byte code; taking the contract byte code as an under-chain byte code of the smart contract, and screening out the event byte code from the contract byte code to generate an on-chain byte code of the smart contract; deploying the on-chain byte code to a block chain network, and replacing and deploying the on-chain byte code in a second block chain node in the block chain network as an under-chain byte code; and the second block chain node is used for performing under-chain storage on the contract event of the smart contract based on the event byte code in the under-chain byte code, so that the flexibility and convenience of storing and modifying the contract event can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of blockchains, and in particular to a data processing method and device for a blockchain network, a product, an apparatus, and a medium. BACKGROUND

[0002] A smart contract is a code that can be executed on a blockchain and can realize automatic transaction execution. A contract event of a smart contract is a log printed on a blockchain when a transaction is executed.

[0003] A current contract event is compiled into event bytecode and deployed on a blockchain as part of contract bytecode of a smart contract compilation, but because the storage space of contract bytecode on a blockchain is limited and has the characteristics of being tamper-proof, the storage and modification of a contract event on a blockchain are very limited. Therefore, how to improve the flexibility and convenience of storage and modification of a contract event is a problem that needs to be solved. SUMMARY

[0004] The present application provides a data processing method and device for a blockchain network, a product, an apparatus, and a medium, which can improve the flexibility and convenience of storage and modification of a contract event.

[0005] The present application provides a data processing method for a blockchain network, which is applied to a first blockchain node. The method comprises the following steps:

[0006] A smart contract to be deployed is obtained, and the smart contract is compiled and processed according to a data format suitable for a blockchain network to generate contract bytecode of the smart contract. The contract bytecode contains event bytecode, and the event bytecode is used to obtain a contract event of the smart contract.

[0007] The contract bytecode is used as off-chain bytecode of the smart contract, and the event bytecode is filtered out from the contract bytecode to generate on-chain bytecode of the smart contract.

[0008] The on-chain bytecode is deployed into a blockchain network, and the on-chain bytecode in a second blockchain node in the blockchain network is replaced and deployed as off-chain bytecode. The second blockchain node is used to store a contract event of the smart contract off-chain based on the event bytecode in the off-chain bytecode.

[0009] The present application provides a data processing method for a blockchain network. The blockchain network comprises a second blockchain node, and the second blockchain node has deployed off-chain bytecode of a smart contract. The off-chain bytecode contains event bytecode, and the event bytecode is used to obtain a contract event of the smart contract. The method is applied to the second blockchain node in the blockchain network. The method comprises the following steps:

[0010] The target blockchain transaction needs to call the smart contract for processing is acquired;

[0011] The target blockchain transaction is executed based on the deployed off-chain bytecode to generate a contract event associated with the target blockchain transaction;

[0012] The generated contract event is stored off-chain.

[0013] Embodiments of the present application provide a data processing apparatus of a blockchain network, the apparatus is applied to a first blockchain node, and the apparatus comprises:

[0014] An acquisition module is configured to acquire a smart contract to be deployed;

[0015] A processing module is configured to compile and process the smart contract according to a data format adaptive to the blockchain network to generate contract bytecode of the smart contract; the contract bytecode comprises event bytecode, and the event bytecode is used to acquire a contract event of the smart contract;

[0016] The processing module is further configured to take the contract bytecode as off-chain bytecode of the smart contract, and filter out the event bytecode from the contract bytecode to generate on-chain bytecode of the smart contract;

[0017] The processing module is further configured to deploy the on-chain bytecode to the blockchain network, and replace and deploy the on-chain bytecode in a second blockchain node in the blockchain network as off-chain bytecode; the second blockchain node is configured to store the contract event of the smart contract off-chain based on the event bytecode in the off-chain bytecode.

[0018] Embodiments of the present application provide a data processing apparatus of a blockchain network, the blockchain network comprises a second blockchain node, and off-chain bytecode of a smart contract is deployed in the second blockchain node; the off-chain bytecode comprises event bytecode, and the event bytecode is used to acquire a contract event of the smart contract, the apparatus is applied to the second blockchain node in the blockchain network; the apparatus comprises:

[0019] An acquisition module is configured to acquire a target blockchain transaction needing to call the smart contract for processing;

[0020] A processing module is configured to execute the target blockchain transaction based on the deployed off-chain bytecode to generate a contract event associated with the target blockchain transaction;

[0021] The processing module is further configured to store the generated contract event off-chain.

[0022] Embodiments of the present application provide a computer device, which comprises a memory and a processor, the memory stores a computer program, and the computer program is executed by the processor to enable the processor to execute the data processing method of the blockchain network.

[0023] The embodiment of the present application further provides a computer readable storage medium, which stores a computer program. The computer program is executed by a processor to make the processor execute the data processing method of the blockchain network.

[0024] The embodiment of the present application further provides a computer program product, which comprises a computer program stored in a computer readable storage medium. A processor of a computer device reads the computer program from the computer readable storage medium, and the processor executes the computer program to make the computer device execute the data processing method of the blockchain network.

[0025] In the embodiment of the present application, the first blockchain node can obtain the smart contract to be deployed, and compile the smart contract according to a data format suitable for the blockchain network to generate contract bytecode of the smart contract. The contract bytecode comprises event bytecode, and the event bytecode is used to obtain contract events of the smart contract. The contract bytecode is taken as off-chain bytecode of the smart contract, and the event bytecode is filtered out from the contract bytecode to generate on-chain bytecode of the smart contract. The on-chain bytecode is deployed into the blockchain network, and the on-chain bytecode in the second blockchain node in the blockchain network is replaced and deployed as off-chain bytecode. The second blockchain node is used to store the contract events of the smart contract off-chain based on the event bytecode in the off-chain bytecode. As can be seen, the method provided in the present application can deploy the event bytecode to the second blockchain node when deploying the smart contract, so that the second blockchain node stores the contract events according to the contract events corresponding to the event bytecode, that is, the sending and storage of the contract events are moved off-chain, so that the storage and modification of the contract events of the smart contract are no longer limited, thereby making the contract events achieve the same effect as ordinary logs, that is, no on-chain service charge is needed, no on-chain contract bytecode is occupied, and the contract events can be adjusted as needed, thereby improving the flexibility and convenience of storing and modifying the contract events. BRIEF DESCRIPTION OF DRAWINGS

[0026] In order to more clearly illustrate the technical solutions of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0027] Figure 1 is an architecture schematic diagram of a blockchain network provided by the embodiment of the present application;

[0028] Figure 2 is an architecture schematic diagram of a data processing system provided by the embodiment of the present application;

[0029] Figure 3 is a flowchart of a data processing method of a blockchain network provided by an embodiment of the present application;

[0030] Figure 4 is a flowchart of another data processing method of a blockchain network provided by an embodiment of the present application;

[0031] Figure 5 is a flowchart of a state condition of a first blockchain node and a synchronization node executing a transaction provided by an embodiment of the present application;

[0032] Figure 6 is a state diagram of a first blockchain node and a second blockchain node executing a transaction provided by an embodiment of the present application;

[0033] Figure 7 is a flowchart of another data processing method of a blockchain network provided by an embodiment of the present application;

[0034] Figure 8 is a work flow diagram of a data processing method of a blockchain network provided by an embodiment of the present application;

[0035] Figure 9 is a structural diagram of a data processing device of a blockchain network provided by an embodiment of the present application;

[0036] Figure 10 is a structural diagram of another data processing device of a blockchain network provided by an embodiment of the present application;

[0037] Figure 11 is a structural block diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0038] The technical solutions in the present application will be described clearly and completely below with reference to the drawings in the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of protection of the present application.

[0039] The terminology used in the following embodiments of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the present application. As used in the description of the application and the appended claims, the singular forms "a," "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It also will be understood that the term "and / or," as used herein, refers to and encompasses any and all possible combinations of one or more of the associated listed items.

[0040] It should be noted that the terms "first", "second" and the like in the embodiments of the present application are only used for the purpose of description and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the technical features indicated. Therefore, the technical features limited by "first", "second" can be explicitly or implicitly included at least one of the features.

[0041] First of all, it needs to be explained that all the data collected in the present application (such as deployment transactions and related data) are collected with the consent and authorization of the object to which the data belongs (such as users, institutions or enterprises), and the collection, use and processing of related data need to comply with relevant laws, regulations and standards in the relevant region.

[0042] Here, the related technical concepts involved in the present application are explained:

[0043] Blockchain: a data structure composed of a number of blocks connected by hash values, each block composed of transactions generated within a period of time, packaged by a blockchain node with the right to record, and independently verified by each blockchain node.

[0044] Smart contract: generally considered, smart contract refers to a computer program that can automatically execute contract terms, with characteristics such as event-driven, value transfer, automatic execution, etc.

[0045] Contract event: a contract event is a log printed on the blockchain when a transaction is executed, for example, a token contract will issue an event event Transfer(indexed from, indexed to, uint256 value) after a transfer is executed. Off-chain applications monitor these logs and respond. Currently, the events of smart contracts have three characteristics:

[0046] a) Emitting a contract event is part of the smart contract logic, which is compiled into bytecode and stored on the chain.

[0047] b) Contract events are permanently stored on the blockchain and require storage costs.

[0048] c) Contract events have read-only properties, used to record the log of transaction execution, which basically does not affect the transaction execution and smart contract state update. For example, even if the transfer transaction does not issue a transfer event event Transfer, the transfer will still occur, and the balance of the receiver / sender will still be increased / decreased accordingly.

[0049] Please refer to Figure 1 , Figure 1 is an architecture schematic diagram of a blockchain network provided by an embodiment of the present application. As shown in Figure 1 , the blockchain network 100 can include a consensus network 101 and a synchronization network 102; the nodes in the synchronization network 102 can be referred to as synchronization nodes, which mainly perform business execution and do not participate in the accounting consensus, and obtain block data from the consensus network 101 through identity authentication. The consensus network 101 can also be referred to as a core network, and the nodes in the consensus network 101 can be referred to as consensus nodes, which have full data. Among them, the consensus network 101 and the synchronization network 102 can be in different network environments. Generally, the consensus network 101 is in a private network, and the synchronization network 102 is in a common network, and the two interact through a routing boundary.

[0050] It can be understood that the above-mentioned consensus network 101 can include one or more consensus nodes, and the number of consensus nodes will not be limited here. Please refer to Figure 1 , the consensus network 101 can include a consensus node 1011, a consensus node 1012,..., and a consensus node 1013.

[0051] It can be understood that the above-mentioned synchronization network 102 can include one or more synchronization nodes, and the number of synchronization nodes will not be limited here. Please refer to Figure 1 , the synchronization network 102 can include a synchronization node 1021, a synchronization node 1022, a synchronization node 1023,..., a synchronization node 1024, and a synchronization node 1025.

[0052] In order to ensure the data intercommunication between various blockchain nodes, there can be data connections between each blockchain node, such as a data connection between the consensus node 1011 and the consensus node 1012, a data connection between the consensus node 1011 and the consensus node 1013, a data connection between the synchronization node 1021 and the synchronization node 1023, and the like. Further, there is a data connection between the consensus network 101 and the synchronization network 102, such as a data connection between the consensus node 1011 and the synchronization node 1022, a data connection between the consensus node 1012 and the synchronization node 1023, and the like.

[0053] It can be understood that the blockchain nodes can transmit data or blocks through the above data connection. The data connection between the blockchain nodes can be based on node identification. Each blockchain node in the blockchain network has a corresponding node identification, and each blockchain node can store the node identification of other blockchain nodes connected thereto, so as to subsequently broadcast the obtained data or generated blocks to other blockchain nodes according to the node identification of other blockchain nodes. For example, the consensus node 1011 can maintain a node identification list that saves the node name and node identification of other blockchain nodes, as shown in Table 1.

[0054] Table 1

[0055] Node name Node identification Node 1 000.000.000.000 Node 2 111.111.111.111 … … Node N NNN.NNN.NNN.NNN

[0056] The node identification can be an Internet Protocol (IP) address and any other information that can be used to identify a blockchain node in a blockchain network.

[0057] Suppose the node identification of the consensus node 1011 is FFFFF, the consensus node 1011 can send a data synchronization request to the synchronization node 1021 through the node identification CCCCC, and the synchronization node 1021 can know that the data synchronization request is sent by the consensus node 1011 through the node identification FFFFF. Similarly, the synchronization node 1023 can send a resource consumption transaction to the consensus node 1011 through the node identification FFFFF, and the consensus node 1011 can know that the resource consumption transaction is sent by the synchronization node 1023 through the node identification EEEEE. The data transmission between other nodes is also the same, and therefore will not be described one by one.

[0058] It can be understood that the above data connection is not limited to the connection mode, and can be directly or indirectly connected through wired communication, directly or indirectly connected through wireless communication, or connected through other connection modes, which are not limited in the present application.

[0059] It can be understood that Figure 1The blockchain nodes in the blockchain network in the method include, but are not limited to, terminal devices or servers. The server can be a stand-alone physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and basic cloud computing services such as big data and artificial intelligence platforms. The terminal device includes, but is not limited to, a mobile phone, a computer, a smart voice interactive device, a smart home appliance, a vehicle-mounted terminal, an aircraft, and the like. The terminal device and the server can be directly or indirectly connected through wired or wireless means, and the embodiments of the present application do not limit this.

[0060] The data processing method of the blockchain network provided by the embodiments of the present application can be applied in a data processing system as shown in Figure 2 The data processing system includes a transaction client 10 of a user, a first blockchain node 11 and a second blockchain node 12 in a blockchain network 100. The transaction client 10 is a submission client of a deployment transaction of a smart contract (the contract source code of the smart contract is encapsulated in the deployment transaction). It can be understood that the deployment transaction is submitted to the blockchain network 100 by the transaction client 10, the first blockchain node 11 obtains the deployment transaction, extracts the contract source code of the smart contract, compiles the contract source code into contract bytecode, and filters out event bytecode from the contract bytecode to generate on-chain bytecode of the smart contract; the first blockchain node 11 deploys the on-chain bytecode to the blockchain network 100 to realize the on-chain storage of the smart contract, and replaces and deploys the on-chain bytecode in the second blockchain node 12 in the blockchain network 100 as contract bytecode (i.e., off-chain bytecode).

[0061] In one embodiment, the transaction client 10 can be a mobile phone, a computer, a smart voice interactive device, a smart home appliance, a vehicle-mounted terminal, an aircraft, and the like, the first blockchain node 11 can be any consensus node in a consensus network 101 of the blockchain network 100, and the second blockchain node 12 can be any synchronization node in a synchronization network 102 of the blockchain network 100.

[0062] The terminal device and the blockchain node can be directly or indirectly connected through wired or wireless communication, and the present application does not limit this.

[0063] The data processing method of the blockchain network provided by the embodiments of the present application will be described in further detail below with reference to the accompanying drawings.

[0064] Please refer to Figure 3 , Figure 3is a flowchart of a data processing method of a blockchain network provided by an embodiment of the present application. The execution subject in the embodiment of the present application can be a first blockchain node, which can be any consensus node in the consensus network 101. As shown in Figure 3 The method can specifically include but is not limited to the following steps:

[0065] In step S301, an intelligent contract to be deployed is acquired, and the intelligent contract is compiled according to a data format adaptive to the blockchain network to generate contract bytecode of the intelligent contract. The contract bytecode contains event bytecode, which is used to acquire contract events of the intelligent contract.

[0066] Optionally, the intelligent contract to be deployed can be written by a user in a transaction client using a high-level programming language, and the written intelligent contract is sent to the blockchain network through the transaction client. The first blockchain node can acquire the intelligent contract to be deployed from the blockchain network. The first blockchain node can compile the intelligent contract by using an intelligent contract compiler to generate the contract bytecode of the intelligent contract.

[0067] Optionally, the intelligent contract to be deployed can also be written by the user directly on the first blockchain node using a high-level programming language. The first blockchain node acquires the written intelligent contract. The first blockchain node can also compile the intelligent contract by using an intelligent contract compiler to generate the contract bytecode of the intelligent contract.

[0068] The high-level programming language includes but is not limited to any of the following: Solidity language (a contract-oriented high-level programming language created for implementing intelligent contracts), C++ language (a general object-oriented high-level programming language), Go language (also known as Golang language, a static strong type, compiled type, concurrent type, and high-level programming language with garbage collection function), Rust language (a static type high-level compiled language), python language (an object-oriented dynamic type high-level compiled language), JS language (also known as JavaScript language, a lightweight, interpreted or just-in-time compiled high-level programming language with function priority), Ruby language (a dynamic, object-oriented high-level programming language), and the like. The intelligent contract compiler corresponds to the high-level programming language. The types of the intelligent contract compiler used during compilation are different for different high-level programming languages.

[0069] The first blockchain node can be deployed with a smart contract compiler, which can be used to compile a smart contract written in a high-level programming language into contract bytecode in a data format suitable for the blockchain network. In other words, the first blockchain node can use the smart contract compiler to convert the smart contract code written in a high-level programming language (which can be referred to as contract source code) into an executable and identifiable form in the blockchain network, so that the smart contract can run and execute on the blockchain.

[0070] The specific form of the event bytecode can be as shown in Table 2. As shown in Table 2, the event bytecode can include a plurality of log bytecodes for representing different types of smart contract events. Here, the plurality of log bytecodes can include A0 bytecode, A1 bytecode, A2 bytecode, A3 bytecode, and A4 bytecode, which can be used to represent different types of event bytecodes. The A0 bytecode can be used to represent the signature or identifier of the contract event, which can be used to identify the contract event type defined in the smart contract. The A1 bytecode can be used to represent the number of parameters of the contract event or other related information, which can be used to indicate the number of contract event parameters or other information related to the contract event. The A2 bytecode can be used to represent the type of contract event parameter, which can be used to indicate the data type of the contract event parameter, such as integer, address, string, etc. The A3 bytecode can be used to represent the specific value of the contract event parameter, which can be used to indicate the actual numerical value or content of the contract event parameter. The A4 bytecode can be used to represent the end of the contract event parameter or a separator, which can be used to identify the end of the contract event parameter or separate information between different parameters. Each log bytecode can be associated with its own identification information and bytecode instruction. The bytecode instruction can be an operation code in the smart contract, which can be used to issue a contract event with a topic and record the data at a specified memory location.

[0071] For example, in Table 2, the identification information associated with the A0 bytecode can be LOG0, and the bytecode instruction associated with the A0 bytecode can be LOG0(memory[offset:offset+length]). The identification information associated with the A1 bytecode can be LOG1, and the bytecode instruction associated with the A1 bytecode can be LOG1(memory[offset:offset+length], topic0). Similarly, the remaining event bytecodes in Table 2 are similar and will not be described in detail here.

[0072] Table 2

[0073]

[0074] The bytecode instruction can be used to write a byte array (in memory) into the log (i.e., a contract event), and up to four topics can be specified for each contract event. The topics can be the signature hash of the contract event or the hash of a certain parameter related to the contract event. The topics can have the following functions: classification and filtering, i.e., topics can be used to classify and filter contract events, users can filter the contract events of interest according to specific topics for data analysis, monitoring, or other operations, and this classification and filtering mechanism makes the log of the smart contract more manageable and easier to interpret; relevance, i.e., by taking specific information as topics, different contract events can be linked together, for example, when a smart contract triggers multiple related contract events, the same topic can be used to identify the contract events, so that these contract events can be more easily identified and associated in subsequent processing; indexing, i.e., topics can be used as indexes of contract events, making it more efficient to quickly locate specific types of contract events in the log, external applications can quickly find and access the required log data according to the topics without having to traverse the entire log; event retrieval, i.e., external services or applications can retrieve contract events related to a specific topic according to the topic, this function can be used to build more complex smart contracts, monitor the behavior of smart contracts, or implement more advanced data analysis. In summary, specifying topics can make the contract events of the smart contract more structured and usable, making the log data more manageable, analyzable, and useful. For example, in a contract event, the bytecode instruction can be used to record the state information of the smart contract and send it out as part of the contract event. The bytecode instruction can allow the smart contract developer to flexibly select the information content of the record and process it according to actual needs.

[0075] Example 1, the bytecode instruction of LOG0 can perform the following operations: read a data segment of length length from the specified memory location offset, these data will be recorded as the data part of the log. LOG0 can record information that does not require a classification topic but needs to leave a trace. For example, a smart contract may record the values of key variables when performing a specific function, so that developers or users can verify the behavior of the smart contract or debug the smart contract.

[0076] Example 2, the bytecode instruction of LOG1 can perform the following operations: read a data segment with a length of length from a specified memory location offset, and these data will be recorded as the data part of the log. topic0 is the first topic of the contract event. Each topic can be a 32-byte byte string. LOG1 can be used when the smart contract needs to record certain contract events and classify them under a specific topic. For example, record user transactions, contract state changes, etc. Topics can help users more easily filter and retrieve contract events to achieve more efficient data analysis or monitoring.

[0077] When a smart contract executes a transaction and triggers a contract event of the smart contract, the smart contract can write the event data related to the triggered contract event into the log of the executed transaction. Subsequently, the log of the transaction can be monitored and processed by an external application or other smart contracts, thereby enabling communication and interaction between the smart contract and the external environment (such as the external application or other smart contracts).

[0078] Step S302, the contract bytecode is taken as the off-chain bytecode of the smart contract, and the event bytecode is filtered out from the contract bytecode to generate the on-chain bytecode of the smart contract.

[0079] The first blockchain node can filter out the event bytecode from the contract bytecode. For example, the first blockchain node can use an event bytecode filter to filter the contract bytecode to filter out the event bytecode in the contract bytecode, thereby generating the on-chain bytecode of the smart contract. The generated on-chain bytecode does not contain the event bytecode of the smart contract. For example, the event bytecode (i.e., A0-A4 bytecode) shown in Table 2 can be filtered out from the contract bytecode. It should be noted that filtering out the event bytecode does not affect the execution of the transaction by the smart contract and the state update of the smart contract.

[0080] Step S303, deploy the on-chain bytecode to the blockchain network, and replace and deploy the on-chain bytecode in the second blockchain node in the blockchain network as off-chain bytecode; the second blockchain node is used to store the contract event of the smart contract off-chain based on the event bytecode in the off-chain bytecode.

[0081] The first blockchain node can deploy the on-chain bytecode into the blockchain network, which includes deploying the on-chain bytecode on the first blockchain node and the second blockchain node. Since all transactions occur on the blockchain network, which is the real account book for transactions, and the contract event is used to record the execution state, the on-chain bytecode without the event bytecode does not affect the execution of the transaction and the update of the smart contract state. Then, the first blockchain node can replace and deploy the on-chain bytecode in the second blockchain node as off-chain bytecode. After the second blockchain node synchronizes the on-chain transaction, it will store the contract event of the smart contract off-chain based on the event bytecode in the off-chain bytecode. Subsequently, the second blockchain node can provide a log query service for the smart contract, through which the contract event generated by the smart contract can be queried. The contract event can belong to the log data of the smart contract.

[0082] The second blockchain node can be a modified synchronization node. The contract event can be used not only to record the execution state, but also to notify external observers of information about specific events occurring in the smart contract. The contract event is usually used to record important state changes or trigger specific behaviors. The contract event can contain various types of state information, which can include: state changes (such as asset transfer, account registration, voting results, etc.), execution results of transactions (such as transaction success or transaction failure, etc.), important notifications (such as system upgrade, emergency handling, etc.), and user behavior records (such as user registration, login, order placement, etc.). In general, the contract event is used to record important state changes and notifications related to the smart contract, and to share key events occurring in the smart contract with external observers. Through the contract event, the smart contract can achieve information exchange and communication with the external environment, improving the transparency and usability of the smart contract.

[0083] From the above description, it can be understood that since the contract event can be used to record the execution state, the second blockchain node will have the same state as the blockchain after synchronizing the on-chain transaction, and there will be no inconsistency in the account book. The difference between the first blockchain node and the second blockchain node is that the second blockchain node will store the contract event of the smart contract off-chain based on the event bytecode in the off-chain bytecode after synchronizing the on-chain transaction to provide a log query service. The first blockchain node does not have the event bytecode and will not generate the corresponding log (i.e., the contract event), so it cannot provide a log query service.

[0084] That is, in the embodiment of the present application, the contract event of the smart contract can be issued and generated by the second blockchain node, and the query service for the contract event of the smart contract is provided, while the other blockchain nodes in the blockchain network except the second blockchain node only need to call the deployed on-chain bytecode for transaction execution, without issuing the contract event of the smart contract and storing the contract event of the smart contract, so as to improve the efficiency of the other blockchain nodes in calling the smart contract for transaction execution, and reduce the processing overhead related to the contract event of the smart contract.

[0085] In the embodiment of the present application, the first blockchain node can obtain the smart contract to be deployed, and compile the smart contract according to the data format suitable for the blockchain network to generate the contract bytecode of the smart contract. The contract bytecode includes event bytecode, which is used to obtain the contract event of the smart contract. The contract bytecode is used as the off-chain bytecode of the smart contract, and the event bytecode is filtered out from the contract bytecode to generate the on-chain bytecode of the smart contract. The on-chain bytecode is deployed to the blockchain network, and the on-chain bytecode in the second blockchain node in the blockchain network is replaced and deployed as off-chain bytecode. The second blockchain node is used to store the contract event of the smart contract off-chain based on the event bytecode in the off-chain bytecode. As can be seen, the method proposed in the present application can deploy the event bytecode to the second blockchain node when deploying the smart contract, so that the second blockchain node stores the contract event corresponding to the event bytecode off-chain, that is, the issuance and storage of the contract event are moved off-chain, so that the storage and modification of the contract event of the smart contract are no longer limited, so that the contract event achieves the same effect as the ordinary log, that is, no on-chain service charge is required, no on-chain contract bytecode is occupied, and the contract event can be adjusted as needed, etc., so as to improve the flexibility and convenience of storing and modifying the contract event.

[0086] Please refer to Figure 4 , Figure 4 is a flowchart of another data processing method of a blockchain network provided by the embodiment of the present application. The execution subject in the embodiment of the present application can be a second blockchain node, which can be any synchronization node in the synchronization network 102. As shown in Figure 4 , the method can specifically include but is not limited to the following steps:

[0087] Step S401, obtaining a target blockchain transaction to be processed by calling a smart contract.

[0088] The blockchain network includes a second blockchain node, the second blockchain node is deployed with off-chain bytecode of the smart contract, the off-chain bytecode includes event bytecode, and the event bytecode is used to obtain a contract event of the smart contract. The event bytecode can be used to record a transaction execution state, and the transaction execution state can specifically include a success or failure state (the success state indicates that the transaction is successfully executed, and the failure state indicates that an error or an abnormal condition occurs in the transaction execution process), transaction result data (for example, a return value or a state change of a function call), contract event triggering information (for example, a contract event name and a parameter value), resource consumption, exception information (for example, an error reason and an error code), and the like.

[0089] The second blockchain node can receive a target blockchain transaction sent by the transaction client and requiring calling the smart contract for processing. Specifically, the transaction client can create the target blockchain transaction (for example, a resource transfer transaction) and broadcast the target blockchain transaction to the blockchain network. The second blockchain node can obtain the target blockchain transaction requiring calling the smart contract for processing from the blockchain network. The target blockchain transaction can include transaction identification information and the like.

[0090] Further, in this application, the second blockchain node can also perform signature verification on signature data of the transaction client. The signature data can be obtained by signing to-be-signed data by the transaction client using a private key of the transaction client. The to-be-signed data can be, for example, the target blockchain transaction. The second blockchain node can perform signature verification on the signature data in the following manner: after receiving the target blockchain transaction sent by the transaction client, the second blockchain node obtains a public key corresponding to the transaction client and performs signature verification on the signature data according to the public key, to verify the identity of the transaction client. If the signature verification on the signature data is passed, the second blockchain node can load the corresponding contract bytecode, that is, the off-chain bytecode, according to the smart contract address specified in the transaction. If the signature data fails the signature verification, the second blockchain node will reject the target blockchain transaction.

[0091] In step S402, the target blockchain transaction is executed based on the deployed off-chain bytecode to generate a contract event associated with the target blockchain transaction.

[0092] The smart contract called by the second blockchain node is the deployed off-chain bytecode. The second blockchain node can execute the target blockchain transaction based on the deployed off-chain bytecode. The execution of the target blockchain transaction can involve operations such as modifying a storage state, reading the storage state, and consuming a resource amount. Based on the event bytecode included in the off-chain bytecode, the second blockchain node can generate a contract event associated with the target blockchain transaction.

[0093] Step S403, store the generated contract event off-chain.

[0094] The second blockchain node can store the generated contract event in a local off-chain storage space of the second blockchain node. The local off-chain storage space can be a database.

[0095] Optionally, the second blockchain node can receive an event query request sent by a transaction client, the event query request containing a transaction identifier of a target blockchain transaction, so as to query a contract event associated with the target blockchain transaction from the off-chain stored contract event based on the transaction identifier. That is, when the generated contract event is stored off-chain, the second blockchain node can store the transaction identifier of the target blockchain transaction in association with the contract event. The queried contract event associated with the target blockchain transaction is returned to the transaction client. Therefore, the second blockchain node can provide a log query service.

[0096] The transaction identifier can be a unique identifier or a set of identifiers of the transaction, used to distinguish different transactions. The transaction identifier can include one or more of a transaction hash, a transaction sequence number, a block height, and a timestamp. The transaction hash can be a unique identifier of the transaction, obtained by hashing the transaction data (e.g., the target blockchain transaction). The transaction sequence number can be used to identify the position of the transaction in the block. The block height is used to represent the position of the transaction in the blockchain and is an integer value. The timestamp of the transaction is used to represent the time when the transaction is created or processed.

[0097] The second blockchain node is modified from the synchronization node. If the second blockchain node is not modified from the synchronization node, the states of the first blockchain node and the synchronization node will be inconsistent, as shown in an example in Figure 5 Figure 5 In the example, the first blockchain node deploys on-chain bytecode, and the synchronization node deploys off-chain bytecode, which includes event bytecode. Specifically, when the synchronization node executes the event bytecode in the off-chain bytecode, the corresponding consumed resources are deducted, i.e., y gas is deducted, and the contract event generated based on the event bytecode is stored in the database of the synchronization node. Then, a Merkle tree is generated based on the contract event to obtain a receipt root, and the receipt root is recorded in the block. Generally, the inconsistent states of the first blockchain node and the synchronization node in executing the transaction include the following two aspects:

[0098] ​1. The resources (i.e. represented by gas) that the synchronization node still consumes when executing the event bytecode in the off-chain bytecode. Therefore, the remaining gas (i.e. represented by gas-left) recorded by the synchronization node after executing the event bytecode is x-y. However, the on-chain bytecode executed by the first blockchain node does not contain the event bytecode, and the remaining gas recorded on the blockchain is x. The difference in the remaining gas affects the execution of subsequent transactions.

[0099] 2. The synchronization node can form a Merkle tree with the contract event and transaction issued by the off-chain bytecode and obtain the receipt root thereof, and then record the receipt root in the block. That is, the synchronization node can take the transaction and the contract event associated with the transaction as the data of the leaf node, hash the data of each leaf node to obtain the hash value as the identifier of the leaf node, combine the hash values of adjacent leaf nodes, and hash again to obtain the hash value of the parent node. This process is repeated until only one root node is left. The hash value of the final root node (i.e. the transaction hash and the contract event hash) is the receipt root. Therefore, the receipt root in the block of the synchronization node contains the contract event hash. However, the on-chain bytecode executed by the first blockchain node does not contain the event bytecode, and the receipt root in the block of the blockchain does not contain the contract event hash. The difference in the receipt root affects the hash of the block.

[0100] To ensure that the second blockchain node is synchronized with the on-chain transaction and consistent with the state of the first blockchain node on the blockchain. The embodiment of the present application modifies the synchronization node into the second blockchain node, so that the state of the first blockchain node and the second blockchain node is consistent, as shown in Figure 6 . In Figure 6 , the first blockchain node deploys the on-chain bytecode, and the second blockchain node deploys the off-chain bytecode, which contains the event bytecode. Specifically, the second blockchain node stores the generated contract event in the database of the synchronization node when executing the event bytecode in the off-chain bytecode. The state of the first blockchain node and the second blockchain node executing the transaction can include the following two aspects:

[0101] 1. The second blockchain node can be used to calculate the amount of resources consumed by executing the target blockchain transaction after executing the target blockchain transaction. After the second blockchain node off-chains the generated contract event, there is no resource required to be consumed. It is ensured that the recorded amount of consumed resources is consistent when the on-chain transaction is synchronized to the second blockchain node.

[0102] 2. The second blockchain node can perform a hash calculation on the target blockchain transaction to generate a transaction hash of the target blockchain transaction; generate a transaction voucher of the target blockchain transaction based on the transaction hash; wherein the generated contract event is not used to participate in the generation of the transaction voucher. That is, the second blockchain node can ignore the generated contract event when generating the Merkle tree, thereby ensuring that the block generated by the first blockchain node based on the target blockchain transaction is consistent with the block generated by the second blockchain node based on the target blockchain transaction on the blockchain network.

[0103] In the embodiments of the present application, the second blockchain node is deployed with off-chain bytecode of the smart contract, and the off-chain bytecode includes event bytecode for obtaining contract events of the smart contract. The second blockchain node can obtain a target blockchain transaction that needs to call the smart contract for processing. The target blockchain transaction is executed based on the deployed off-chain bytecode to generate contract events associated with the target blockchain transaction. The generated contract events are stored off-chain. As can be seen, the method proposed in the present application can generate contract events (i.e. logs) associated with the transaction based on the event bytecode after executing the transaction, and the off-chain storage can enable users to query the logs corresponding to the transaction. In addition, since the off-chain bytecode containing the event bytecode only exists on the second blockchain node, the smart contract developer can adjust the contract events as needed at any time, such as adding, deleting, or modifying. The developer only needs to redeploy the new on-chain bytecode in the second blockchain node (such as replacing the original deployed on-chain bytecode with the new on-chain bytecode), so that the developer does not need to consider the problem that the contract events cannot be changed after the smart contract is deployed when developing the smart contract, thereby improving the flexibility and convenience of storing and modifying the contract events.

[0104] Please refer to Figure 7 , Figure 7 is another flowchart of a data processing method of a blockchain provided by the embodiments of the present application. The data processing method of the blockchain network can be executed by the transaction client, the first blockchain node and the second blockchain node. The first blockchain node can be any consensus node in the consensus network 101, and the second blockchain node can be any synchronization node in the synchronization network 102. As shown in Figure 7 , the method can include but is not limited to the following steps:

[0105] Step S701, the transaction client sends a deployment transaction of a smart contract to the first blockchain node.

[0106] In the present application, the smart contract can be deployed in the blockchain network through a transaction, therefore, the first blockchain node can receive the deployment transaction of the smart contract sent by the transaction client, and the deployment transaction is a transaction for deploying the smart contract in the blockchain network.

[0107] The contract source code encapsulates the smart contract in the deployment transaction. The contract source code can be a smart contract code written in a high-level programming language.

[0108] The user can write the contract source code in a high-level programming language using a transaction client, encapsulate the written contract source code into a deployment transaction through the transaction client, and send it to the blockchain network. Thus, the first blockchain node obtains the deployment transaction from the blockchain network.

[0109] In step S702, the first blockchain node extracts the contract source code of the smart contract from the deployment transaction.

[0110] In step S703, the first blockchain node compiles the extracted contract source code according to a data format suitable for the blockchain network to generate the contract bytecode of the smart contract.

[0111] The contract bytecode contains event bytecode, which is used to obtain the contract event of the smart contract.

[0112] The first blockchain node can use a smart contract compiler to compile the smart contract into contract bytecode, that is, to convert the smart contract code written in a high-level programming language into a form executable by the blockchain, so that the smart contract can run and execute on the blockchain.

[0113] In step S704, the first blockchain node takes the contract bytecode as the off-chain bytecode of the smart contract, and filters out the event bytecode from the contract bytecode to generate the on-chain bytecode of the smart contract.

[0114] The contract bytecode contains a plurality of field data obtained by compiling, and the plurality of field data contains field data of the event bytecode. The event bytecode is used to obtain the contract event of the smart contract.

[0115] Alternatively, the first blockchain node identifies the field data of the event bytecode in the contract bytecode; filters out the identified field data of the event bytecode from the contract bytecode to generate the on-chain bytecode.

[0116] The specific implementation of step S704 can refer to the description of the specific implementation of the aforementioned step S302, which will not be repeated here.

[0117] In step S705, the first blockchain node deploys the on-chain bytecode to the blockchain network, and replaces and deploys the on-chain bytecode in the second blockchain node in the blockchain network as off-chain bytecode.

[0118] The second blockchain node is configured to store the contract event of the smart contract off-chain based on the event bytecode in the off-chain bytecode.

[0119] Feasible, the first blockchain node can be used to execute the blockchain transaction that needs to call the smart contract for processing based on the deployed on-chain bytecode; the second blockchain node can be used to execute the blockchain transaction that needs to call the smart contract for processing based on the deployed off-chain bytecode, to generate a contract event associated with the executed blockchain transaction, and to store the generated contract event off-chain.

[0120] The specific implementation of step S705 can refer to the description of the specific implementation of the foregoing step S303, and will not be described here.

[0121] Step S706, the transaction client sends the target blockchain transaction that needs to call the smart contract for processing to the second blockchain node.

[0122] In this application, the second blockchain node can receive the target blockchain transaction that needs to call the smart contract for processing sent by the transaction client.

[0123] The target blockchain transaction can include a transaction identifier of the target blockchain transaction. The transaction identifier can be a unique identifier or a set of identifiers of the transaction, used to distinguish different transactions. The transaction identifier can include one or more of a transaction hash, a transaction serial number, a block height, and a timestamp.

[0124] Specifically, the transaction client can send the target blockchain transaction that needs to call the smart contract for processing to the blockchain network, so that the first blockchain node and the second blockchain node can both obtain the target blockchain transaction that needs to call the smart contract for processing from the blockchain network.

[0125] The specific implementation of step S706 can refer to the description of the specific implementation of the foregoing step S401, and will not be described here.

[0126] Step S707, the second blockchain node executes the target blockchain transaction based on the deployed off-chain bytecode to generate a contract event associated with the target blockchain transaction.

[0127] Feasible, the second blockchain node calculates the resource amount of the resources consumed by executing the target blockchain transaction after executing the target blockchain transaction; and the generated contract event is stored off-chain in the second blockchain node, and there is no required consumed resource.

[0128] The second blockchain node can perform a hash calculation on the target blockchain transaction to generate a transaction hash of the target blockchain transaction, and generate a transaction voucher of the target blockchain transaction based on the transaction hash. The generated contract event is not used to participate in the generation of the transaction voucher. The transaction voucher can be a receipt root, which can be recorded in a block generated based on the packaging of the target blockchain transaction.

[0129] The specific implementation of step S707 can refer to the description of the specific implementation of the foregoing step S402, and will not be described here again.

[0130] In step S708, the second blockchain node stores the generated contract event off-chain.

[0131] The second blockchain node can store the transaction identifier of the target blockchain transaction in association with the contract event.

[0132] The specific implementation of step S708 can refer to the description of the specific implementation of the foregoing step S403, and will not be described here again.

[0133] In step S709, the transaction client sends an event query request to the second blockchain node.

[0134] That is, the second blockchain node receives the event query request sent by the transaction client.

[0135] The event query request can include the transaction identifier of the target blockchain transaction.

[0136] In step S710, the second blockchain node queries the contract event associated with the target blockchain transaction from the contract event stored off-chain based on the transaction identifier.

[0137] In step S711, the second blockchain node sends the queried contract event associated with the target blockchain transaction to the transaction client.

[0138] That is, the transaction client receives the queried contract event associated with the target blockchain transaction sent by the second blockchain node.

[0139] The method proposed in the present application can deploy event bytecode on the second blockchain node when deploying a smart contract, so that the second blockchain node stores the contract event off-chain according to the contract event corresponding to the event bytecode, that is, the issuance and storage of the contract event are moved off-chain, so that the storage and modification of the contract event of the smart contract are no longer limited, so that the contract event achieves the same utility as a normal log, that is, no on-chain fees are required, no contract bytecode is occupied on the chain, and the contract event can be adjusted on demand, etc., thereby improving the flexibility and convenience of storing and modifying the contract event.

[0140] In the following, based on Figure 7 , in combination with Figure 8 , the workflow of the blockchain network data processing method is described in its entirety. As shown in Figure 8 , the first blockchain node compiles the contract source code into contract bytecode, and then obtains on-chain bytecode without event bytecode by passing the contract bytecode through an event bytecode filter. The on-chain bytecode is deployed on the blockchain network, and the contract bytecode is taken as off-chain bytecode, which contains event bytecode. Then, the second blockchain node replaces the on-chain bytecode with the off-chain bytecode. The blockchain network synchronizes transactions to the second blockchain node, that is, the second blockchain node synchronously executes on-chain transactions. At the same time, the user needs to request the second blockchain node to query the log, that is, the second blockchain node provides a log query service.

[0141] Please refer to Figure 9 , Figure 9 is a structural schematic diagram of a data processing apparatus provided by an embodiment of the present application. As shown in Figure 9 , the data processing apparatus 1 can include an acquisition module 901 and a processing module 902.

[0142] The acquisition module 901 is configured to acquire a smart contract to be deployed.

[0143] The processing module 902 is configured to compile and process the smart contract according to a data format adapted to a blockchain network, to generate contract bytecode of the smart contract. The contract bytecode contains event bytecode, and the event bytecode is used to acquire contract events of the smart contract.

[0144] The processing module 902 is further configured to take the contract bytecode as off-chain bytecode of the smart contract, and filter out the event bytecode from the contract bytecode, to generate on-chain bytecode of the smart contract.

[0145] The processing module 902 is further configured to deploy the on-chain bytecode to the blockchain network, and replace and deploy the on-chain bytecode in a second blockchain node in the blockchain network as off-chain bytecode. The second blockchain node is configured to store the contract events of the smart contract off-chain based on the event bytecode in the off-chain bytecode.

[0146] Optionally, the data processing apparatus 1 acquires the smart contract to be deployed in the following manner:

[0147] acquires a deployment transaction of the smart contract; the deployment transaction encapsulates contract source code of the smart contract;

[0148] extracts the contract source code of the smart contract from the deployment transaction;

[0149] The data processing apparatus 1 compiles the smart contract according to a data format adaptive to the blockchain network to generate the contract bytecode of the smart contract in the following manner:

[0150] The extracted contract source code is compiled according to a data format adaptive to the blockchain network to generate the contract bytecode of the smart contract.

[0151] Optionally, the contract bytecode includes a plurality of field data obtained through compilation, and the plurality of field data includes field data of the event bytecode; and the data processing apparatus 1 filters the event bytecode from the contract bytecode to generate the on-chain bytecode of the smart contract in the following manner:

[0152] Identify the field data of the event bytecode in the contract bytecode.

[0153] Filter the identified field data of the event bytecode from the contract bytecode to generate the on-chain bytecode.

[0154] Optionally, the first blockchain node is configured to execute a blockchain transaction that needs to call the smart contract for processing based on the deployed on-chain bytecode.

[0155] The second blockchain node is configured to execute a blockchain transaction that needs to call the smart contract for processing based on the deployed off-chain bytecode, to generate a contract event associated with the executed blockchain transaction, and to store the generated contract event off-chain.

[0156] According to an embodiment of the present application, Figure 3 The steps involved in the data processing method shown can be executed by Figure 9 Each module in the data processing apparatus 1 shown. For example, Figure 3 The obtaining of the smart contract to be deployed in step S301 shown in the method can be executed by Figure 9 The object obtaining module 901 in the apparatus, Figure 3 The compiling of the smart contract according to a data format adaptive to the blockchain network to generate the contract bytecode of the smart contract in step S301 shown in the method can be executed by Figure 9 The object processing module 902 in the apparatus; Figure 3 Step S302 shown in the method can be executed by Figure 9 The processing module 902 in the apparatus; Figure 3 Step S303 shown in the method can be executed by Figure 9 The processing module 902 in the apparatus.

[0157] In the present application, the first blockchain node can obtain the smart contract to be deployed, and compile the smart contract according to a data format suitable for the blockchain network to generate contract bytecode of the smart contract; the contract bytecode contains event bytecode, and the event bytecode is used to obtain contract events of the smart contract; the contract bytecode is taken as off-chain bytecode of the smart contract, and the event bytecode is filtered out from the contract bytecode to generate on-chain bytecode of the smart contract; the on-chain bytecode is deployed into the blockchain network, and the on-chain bytecode in the second blockchain node in the blockchain network is replaced and deployed as off-chain bytecode; the second blockchain node is used to store the contract events of the smart contract off-chain based on the event bytecode in the off-chain bytecode. As can be seen, the device proposed in the present application can deploy the event bytecode to the second blockchain node when deploying the smart contract, so that the second blockchain node stores the contract events according to the contract events corresponding to the event bytecode, that is, the sending and storage of the contract events are moved off-chain, so that the storage and modification of the contract events of the smart contract are no longer limited, thereby making the contract events achieve the same effect as ordinary logs, that is, no on-chain service charge is needed, no on-chain contract bytecode is occupied, and the contract events can be adjusted as needed, and the like.

[0158] According to an embodiment of the present application, Figure 9 Each module in the data processing device 1 shown can be combined into one or several units respectively or all, or some of the units can be further split into a plurality of sub-units with smaller functions, and the same operations can be implemented without affecting the implementation of the technical effects of the embodiments of the present application. The above modules are divided based on logical functions, and the functions of one module can also be implemented by multiple units, or the functions of multiple modules can be implemented by one unit. In other embodiments of the present application, the data processing device 1 can also include other units, and these functions can also be implemented by other units in actual application, and can be implemented by multiple units in cooperation.

[0159] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works with other related parts to achieve a predetermined target, and can be implemented entirely or partially by using software, hardware (such as a processing circuit or a memory) or a combination thereof. Similarly, one processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of an integral module or unit that includes the functions of the module or unit.

[0160] According to an embodiment of the present application, the data processing apparatus 1 shown in FIG. 1 can be constructed by running a computer program capable of performing the steps involved in the corresponding method shown in the embodiments of the present application on a general computer device (which can include central processing units (CPUs), random access memory (RAM), read-only memory (ROM), and other processing and storage elements). Figure 9 The above computer program can be recorded on a computer readable recording medium, and can be loaded into the above computer device through the computer readable recording medium and run therein.

[0161] Please refer to Figure 10 , Figure 10 is a structural schematic diagram of a data processing apparatus provided by an embodiment of the present application. As shown in Figure 10 , the data processing apparatus 2 can include an acquisition module 1001 and a processing module 1002.

[0162] The acquisition module 1001 is configured to acquire a target blockchain transaction that needs to be processed by invoking a smart contract;

[0163] The processing module 1002 is configured to execute the target blockchain transaction based on the deployed off-chain bytecode to generate a contract event associated with the target blockchain transaction;

[0164] The processing module 1002 is further configured to store the generated contract event off-chain.

[0165] Optionally, the second blockchain node is configured to calculate a resource amount of resources consumed by executing the target blockchain transaction; and

[0166] The generated contract event is stored off-chain in the second blockchain node, and the resources required to be consumed do not exist.

[0167] Optionally, the data processing apparatus 2 is further configured to:

[0168] perform hash calculation on the target blockchain transaction to generate a transaction hash of the target blockchain transaction;

[0169] generate a transaction voucher of the target blockchain transaction based on the transaction hash;

[0170] The generated contract event is not used to participate in the generation of the transaction voucher.

[0171] Optionally, the data processing apparatus 2 is further configured to:

[0172] receive an event query request sent by a transaction client; the event query request includes a transaction identifier of the target blockchain transaction;

[0173] query, from the off-chain stored contract events based on the transaction identifier, the contract events associated with the target blockchain transaction;

[0174] return the queried contract events associated with the target blockchain transaction to the transaction client.

[0175] According to an embodiment of the present application, Figure 4 The steps involved in the data processing method shown can be executed by Figure 10 The modules in the data processing apparatus 2 shown can execute the steps. For example, Figure 4 The step S401 shown in the method can be executed by Figure 10 the object acquisition module 1001 in the apparatus; Figure 4 The step S402 shown in the method can be executed by Figure 10 the processing module 1002 in the apparatus; Figure 4 The step S403 shown in the method can be executed by Figure 10 the processing module 1002 in the apparatus.

[0176] In the present application, the off-chain bytecode of the smart contract deployed in the second blockchain node contains event bytecode, which is used to obtain contract events of the smart contract; the second blockchain node can obtain a target blockchain transaction that needs to call the smart contract for processing; the target blockchain transaction is executed based on the deployed off-chain bytecode to generate contract events associated with the target blockchain transaction; and the generated contract events are stored off-chain. As can be seen, the apparatus proposed in the present application can generate contract events (i.e. logs) associated with transactions based on event bytecode after executing transactions, and storing off-chain can enable users to query logs corresponding to transactions. In addition, since the off-chain bytecode containing event bytecode only exists in the second blockchain node, the smart contract developer can perform adjustment operations such as adding, deleting, and modifying contract events at any time as needed, and the developer only needs to redeploy the new on-chain bytecode in the second blockchain node (such as replacing the original deployed on-chain bytecode with the new on-chain bytecode), so that the developer does not need to consider the problem that contract events cannot be changed after the smart contract is deployed when developing the smart contract, thereby improving the flexibility and convenience of storing and modifying contract events.

[0177] According to an embodiment of the present application, Figure 10The various modules in the illustrated data processing apparatus 2 can be combined into one or several units respectively or in total, or some of the units can be further split into a plurality of sub-units that are functionally smaller, which can achieve the same operation without affecting the implementation of the technical effects of the embodiments of the present application. The above modules are divided based on logical functions, and in actual applications, the functions of one module can also be implemented by a plurality of units, or the functions of a plurality of modules can be implemented by one unit. In other embodiments of the present application, the data processing apparatus 2 can also include other units, and in actual applications, these functions can also be assisted by other units, and can be implemented by a plurality of units in cooperation.

[0178] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined target, and can be implemented entirely or partially by using software, hardware (such as a processing circuit or a memory) or a combination thereof. Similarly, one processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of an integral module or unit that includes the functions of the module or unit.

[0179] According to an embodiment of the present application, a computer program capable of executing the steps involved in the corresponding method illustrated in the embodiments of the present application can be run on a general-purpose computer device (which can include a central processing unit (CPU), a random access storage medium (RAM), a read-only storage medium (ROM), and other processing elements and storage elements) to construct the data processing apparatus 2 illustrated in the embodiments of the present application. The above computer program can be recorded on a computer readable recording medium, and can be loaded into the above computer device through the computer readable recording medium and run therein. Figure 10

[0180] Please refer to Figure 11 , Figure 11 is a structural schematic diagram of a computer device provided by the embodiments of the present application. As Figure 11 ​As shown, the computer device 1100 can include a processor 1101, a network interface 1104 and a memory 1105, and in some embodiments, the computer device 1100 can further include a user interface 1103 and at least one communication bus 1102. The communication bus 1102 is used to realize the connection communication between the components. The user interface 1103 can include a display, a keyboard, and the optional user interface 1103 can further include a standard wired interface, a wireless interface. The network interface 1104 can optionally include a standard wired interface, a wireless interface (such as a WI-FI interface). The memory 1105 can be a high-speed RAM memory, or a non-volatile memory, such as at least one disk storage. The memory 1105 can also be at least one storage device located away from the aforementioned processor 1101. As Figure 11 As shown, the memory 1105 as a computer storage medium can include an operating system, a network communication module, a user interface module and a device control application.

[0181] In Figure 11 In the computer device 1100 as shown, the network interface 1104 can provide network communication functions; the user interface 1103 is mainly used to provide an input interface for the user; and the processor 1101 can be used to call the device control application stored in the memory 1105 to realize:

[0182] Obtain the smart contract to be deployed, and compile the smart contract according to a data format suitable for the blockchain network to generate contract bytecode of the smart contract; the contract bytecode includes event bytecode, and the event bytecode is used to obtain contract events of the smart contract;

[0183] The contract bytecode is used as off-chain bytecode of the smart contract, and the event bytecode is filtered out from the contract bytecode to generate on-chain bytecode of the smart contract;

[0184] The on-chain bytecode is deployed into the blockchain network, and the on-chain bytecode in the second blockchain node in the blockchain network is replaced and deployed as off-chain bytecode; the second blockchain node is used to store the contract events of the smart contract off-chain based on the event bytecode in the off-chain bytecode.

[0185] In Figure 11In the computer device 1100 shown, the network interface 1104 can provide network communication functions; and the user interface 1103 is mainly used to provide an interface for user input; the off-chain bytecode of the smart contract deployed in the second blockchain node, the off-chain bytecode includes event bytecode, and the event bytecode is used to obtain a contract event of the smart contract. Therefore, the processor 1101 can be used to call the device control application stored in the memory 1105 to implement:

[0186] obtaining a target blockchain transaction that needs to call a smart contract for processing;

[0187] executing the target blockchain transaction based on the deployed off-chain bytecode to generate a contract event associated with the target blockchain transaction;

[0188] storing the generated contract event off-chain.

[0189] It should be understood that the computer device 1100 described in the embodiments of the present application can execute the description of the above data processing method in the embodiments of the present application, and can also execute the description of the above data processing device 1 in the embodiments of the present application Figure 9 corresponding to the foregoing, and the description of the above data processing device 2 in the embodiments of the present application, which will not be repeated here. In addition, the beneficial effects of using the same method will not be described. Figure 10

[0190] In addition, it should be noted that the present application also provides a computer readable storage medium, and the computer readable storage medium stores a computer program, and when the processor executes the computer program, the computer program can execute the description of the data processing method in the embodiments of the present application, therefore, the description will not be repeated here. In addition, the beneficial effects of using the same method will not be described. For technical details of the computer storage medium embodiments involved in the present application, please refer to the description of the method embodiments of the present application.

[0191] As an example, the above computer program can be deployed on a computer device for execution, or deployed on multiple computer devices located in one place for execution, or deployed on multiple computer devices distributed in multiple places and interconnected through a communication network for execution. The multiple computer devices distributed in multiple places and interconnected through a communication network can constitute a blockchain network.

[0192] ​The computer readable storage medium can be an internal storage unit of the computer device, for example, a hard disk or a memory of the computer device. The computer readable storage medium can also be an external storage device of the computer device, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card and the like. Further, the computer readable storage medium can include both the internal storage unit and the external storage device of the computer device. The computer readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer readable storage medium can also be used to temporarily store data that has been output or will be output.

[0193] The present application provides a computer program product including a computer program stored in a computer readable storage medium. A processor of a computer device reads the computer program from the computer readable storage medium, and the processor executes the computer program to enable the computer device to perform the data access method of the distributed memory architecture described in the embodiments of the present application. Therefore, the description will not be repeated here. In addition, the beneficial effects of using the same method will not be repeated. For technical details not disclosed in the embodiments of the computer readable storage medium, please refer to the description of the method embodiments of the present application.

[0194] The terms "first", "second", and the like in the description and claims of the present application and the accompanying drawings are used to distinguish different objects, and are not used to describe a specific order. In addition, the term "comprising" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, device, product or equipment including a series of steps or units is not limited to the listed steps or units, but can optionally include steps or units not listed, or can optionally include other steps or units inherent to the process, method, device, product or equipment.

[0195] Those of ordinary skill in the art can realize that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been described in general terms in the above description. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. A person skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0196] The above descriptions are only the preferred embodiment of the application, of course, cannot be used to limit the scope of the application, thus the equivalent variations made by the claims of the application, still belongs to the scope of the application covered.

Claims

1. A data processing method for a blockchain network, characterized in that, The method is applied to a first blockchain node, and the method includes: The smart contract to be deployed is obtained, and the smart contract is compiled according to a data format adapted to the blockchain network to generate the contract bytecode of the smart contract; the contract bytecode contains event bytecode, which is used to obtain the contract events of the smart contract; The contract bytecode is used as the off-chain bytecode of the smart contract, and the event bytecode is filtered out from the contract bytecode to generate the on-chain bytecode of the smart contract. The on-chain bytecode is deployed to the blockchain network, and the on-chain bytecode in the second blockchain node of the blockchain network is replaced and deployed as the off-chain bytecode; the second blockchain node is used to store the contract events of the smart contract off-chain based on the event bytecode in the off-chain bytecode.

2. The method according to claim 1, characterized in that, The process of obtaining the smart contract to be deployed includes: Obtain the deployment transaction of the smart contract; the deployment transaction encapsulates the contract source code of the smart contract; Extract the source code of the smart contract from the deployment transaction; The step of compiling the smart contract according to a data format adapted to the blockchain network to generate the smart contract's bytecode includes: The extracted contract source code is compiled according to the data format adapted to the blockchain network to generate the contract bytecode of the smart contract.

3. The method according to claim 1, characterized in that, The contract bytecode contains multiple fields of data compiled from it, and these multiple fields of data include the field data of the event bytecode. The step of filtering out the event bytecode from the contract bytecode to generate the on-chain bytecode of the smart contract includes: Identify the field data of the event bytecode in the contract bytecode; The field data of the identified event bytecode is filtered out from the contract bytecode to generate the on-chain bytecode.

4. The method according to claim 1, characterized in that, The first blockchain node is used to execute blockchain transactions that require the smart contract to be called, based on the deployed on-chain bytecode. The second blockchain node is used to execute blockchain transactions that require the smart contract to be called based on the deployed off-chain bytecode, in order to generate contract events associated with the executed blockchain transactions, and to store the generated contract events off-chain.

5. A data processing method for a blockchain network, characterized in that, The blockchain network includes a second blockchain node, on which off-chain bytecode of a smart contract is deployed. This off-chain bytecode contains event bytecode, which is used to obtain contract events of the smart contract. The method is applied to the second blockchain node. The method includes: Obtain the target blockchain transaction that needs to be processed by calling the smart contract; The target blockchain transaction is executed based on the deployed off-chain bytecode to generate contract events associated with the target blockchain transaction; The generated contract events are stored off-chain.

6. The method according to claim 5, characterized in that, After executing the target blockchain transaction, the second blockchain node is used to calculate the amount of resources consumed in executing the target blockchain transaction; as well as, After the generated contract event is stored off-chain in the second blockchain node, no resources are required.

7. The method according to claim 5, characterized in that, The method further includes: Perform hash calculation on the target blockchain transaction to generate the transaction hash of the target blockchain transaction; A transaction certificate for the target blockchain transaction is generated based on the transaction hash; The generated contract events are not used to participate in the generation of the transaction credentials.

8. The method according to claim 5, characterized in that, The method further includes: Receive an event query request sent by the transaction client; the event query request contains the transaction identifier of the target blockchain transaction; Based on the transaction identifier, query the contract events associated with the target blockchain transaction from the off-chain stored contract events; The queried contract events associated with the target blockchain transaction are returned to the transaction client.

9. A data processing device for a blockchain network, characterized in that, The device is applied to a first blockchain node, and the device includes: The acquisition module is used to acquire the smart contracts to be deployed; The processing module is used to compile the smart contract according to a data format adapted to the blockchain network to generate the contract bytecode of the smart contract; the contract bytecode includes event bytecode, which is used to obtain the contract events of the smart contract; The processing module is further configured to use the contract bytecode as the off-chain bytecode of the smart contract, and to filter out the event bytecode from the contract bytecode to generate the on-chain bytecode of the smart contract. The processing module is further configured to deploy the on-chain bytecode to the blockchain network, and replace and deploy the on-chain bytecode in the second blockchain node of the blockchain network as the off-chain bytecode; the second blockchain node is configured to store the contract events of the smart contract off-chain based on the event bytecode in the off-chain bytecode.

10. A data processing device for a blockchain network, characterized in that, The blockchain network includes a second blockchain node, on which off-chain bytecode of a smart contract is deployed. This off-chain bytecode includes event bytecode, which is used to obtain contract events of the smart contract. The device is applied to the second blockchain node. The device includes: The acquisition module is used to acquire target blockchain transactions that need to be processed by calling the smart contract. A processing module is used to execute the target blockchain transaction based on the deployed off-chain bytecode to generate contract events associated with the target blockchain transaction; The processing module is also used to store the generated contract events off-chain.

11. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the steps of the method according to any one of claims 1-4, or implements the steps of the method according to any one of claims 5-8.

12. A computer device, characterized in that, The method includes a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of the method according to any one of claims 1-4, or causes the processor to perform the steps of the method according to any one of claims 5-8.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that is adapted to be loaded by a processor and executed as described in any one of claims 1-4, or loaded and executed as described in any one of claims 5-8.