Blockchain-based Data Processing Method, Apparatus and Related Equipment
By assigning high priority to timeliness smart contracts in the blockchain network, the problem of timeliness in the existing technology cannot be met is solved, and the timely packaging and contract triggering of internal transaction data is achieved.
Patent Information
- Application Number
- CN202110268849.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-12
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2041-08-05
AI Technical Summary
In the existing blockchain technology, the triggering of some smart contracts deployed is timely, but the existing packaging method cannot guarantee that the transaction data to be packaged will be selected in time, resulting in the timeliness being unable to meet.
Deploy the first smart contract in the blockchain network, obtain internal transaction data and give it priority to the transaction data to be packaged, and generate blocks through the accounting nodes, and broadcast it to the blockchain network to ensure timeliness.
The priority packaging of internal transaction data with high packaging priority is realized, ensuring the timeliness of the trigger of the first smart contract, and solving the problem that timeliness cannot be met in the existing technology.
Smart Images

Figure CN113034137B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of blockchain technology, and more specifically, to a blockchain-based data processing method, device, electronic device, and computer-readable medium. Background Art
[0002] In current blockchain technology, transaction data to be packaged is first placed in the transaction pool of the blockchain network. When packaging blocks, miners (accounting nodes) can select target transaction data to be packaged from the transaction pool based on factors such as the amount of rewards given for each transaction data to be packaged, and package the selected target transaction data to be packaged into the current block. This packaging method will have the following problems: the triggering of some smart contracts deployed in the blockchain network is time-sensitive. The packaging method in related technologies cannot guarantee that the transaction data to be packaged corresponding to the triggering of these time-sensitive smart contracts is selected from the transaction pool in a timely manner for packaging. This will result in the triggering conditions of these time-sensitive smart contracts no longer being met when these time-sensitive smart contracts are actually triggered.
[0003] Therefore, a new blockchain-based data processing method, device, electronic device and computer-readable medium are needed.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute prior art known to ordinary technicians in the field. Summary of the Invention
[0005] The embodiments of the present disclosure provide a blockchain-based data processing method, device, electronic device, and computer-readable medium, thereby at least to a certain extent resolving the problem of unsatisfactory timeliness in related technologies.
[0006] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by practice of the present disclosure.
[0007] The disclosed embodiments provide a blockchain-based data processing method. The blockchain network includes a ledger node, a first smart contract is deployed in the blockchain network, and the method is executed by the ledger node. The blockchain network includes a transaction pool, which includes transaction data to be packaged. The method includes: obtaining internal transaction data, wherein the internal transaction data is obtained by triggering the first smart contract, and the packaging priority of the internal transaction data is higher than that of at least part of the transaction data to be packaged; packaging the internal transaction data to generate a first block; and broadcasting the first block to the blockchain network.
[0008] The disclosed embodiments provide a blockchain-based data processing device, wherein the blockchain network includes a bookkeeping node, a first smart contract is deployed in the blockchain network, and the method is executed by the bookkeeping node. The blockchain network includes a transaction pool, which includes transaction data to be packaged. The device includes: an internal transaction data acquisition unit for acquiring internal transaction data, wherein the internal transaction data is obtained by triggering the first smart contract, and the packaging priority of the internal transaction data is higher than that of at least part of the transaction data to be packaged; a first block generation unit for packaging the internal transaction data to generate a first block; and a first block broadcasting unit for broadcasting the first block to the blockchain network.
[0009] In some exemplary embodiments of the present disclosure, a second smart contract is further deployed in the blockchain network. The internal transaction data acquisition unit includes: a second smart contract invoking unit configured to invoke the second smart contract; a trigger condition determination unit configured to utilize the second smart contract to determine whether the trigger condition of the first smart contract is satisfied; and a first smart contract triggering unit configured to trigger the execution of the first smart contract through the second smart contract to generate the internal transaction data.
[0010] In some exemplary embodiments of the present disclosure, a second smart contract is further deployed in the blockchain network, and the blockchain network also includes non-bookkeeping nodes. The internal transaction data acquisition unit includes an internal transaction data receiving unit configured to receive the internal transaction data from the non-bookkeeping nodes. The non-bookkeeping nodes are configured to invoke the second smart contract, determine through the second smart contract whether the triggering conditions of the first smart contract are satisfied, trigger the execution of the first smart contract using the second smart contract, and generate and broadcast the internal transaction data.
[0011] In some exemplary embodiments of the present disclosure, the second smart contract includes an action function. The first smart contract triggering unit includes an action function triggering unit configured to invoke the action function to trigger the first smart contract and generate the internal transaction data. The apparatus further includes a first target transaction data to be packaged selecting unit configured to select target transaction data to be packaged from the transaction data to be packaged in the transaction pool after invoking the action function to trigger the first smart contract and generating the internal transaction data; and a first target transaction data to be packaged packaging unit configured to package the target transaction data to be packaged into the first block.
[0012] In some exemplary embodiments of the present disclosure, the second smart contract includes an action function. The first smart contract triggering unit includes: a first internal transaction generating unit configured to generate an internal transaction based on the action function and the first smart contract; an internal transaction packaging unit configured to package the internal transaction into the first block; a second target transaction data to be packaged selecting unit configured to select target transaction data to be packaged from the transaction data to be packaged in the transaction pool; a second target transaction data to be packaged packaging unit configured to package the target transaction data to be packaged into the first block; and a first internal transaction executing unit configured to execute the internal transaction in the first block to trigger the first smart contract to generate the internal transaction data.
[0013] In some exemplary embodiments of the present disclosure, the second smart contract includes an action function. The first smart contract triggering unit includes: a second internal transaction generating unit configured to generate an internal transaction based on the action function and the first smart contract; and a packaging contract triggering unit configured to trigger the first smart contract and generate the internal transaction data during the packaging of the internal transaction into the first block.
[0014] In some exemplary embodiments of the present disclosure, the second smart contract includes an action function. The first smart contract triggering unit includes: a third internal transaction generating unit configured to generate an internal transaction based on the action function and the first smart contract; an internal transaction placing unit configured to place the internal transaction into the transaction pool; a to-be-packaged data selecting unit configured to select target to-be-packaged transaction data from the transaction pool among the internal transaction and the to-be-packaged transaction data; a to-be-packaged data packaging unit configured to package the internal transaction and the target to-be-packaged transaction data into the first block; and a second internal transaction executing unit configured to execute the internal transaction in the first block, trigger the first smart contract, and generate the internal transaction data.
[0015] In some exemplary embodiments of the present disclosure, the second smart contract includes an action function. The first smart contract triggering unit includes: a fourth internal transaction generating unit configured to generate at least one internal transaction based on the action function and the first smart contract; multiple internal transaction packaging units configured to package each internal transaction into the first block; and a first block execution unit configured to execute each internal transaction in the first block, triggering the corresponding first smart contract and generating the internal transaction data.
[0016] In some exemplary embodiments of the present disclosure, the device further includes: a third target transaction data to be packaged packaging unit, used to select target transaction data to be packaged from the transaction data to be packaged in the transaction pool; a second block packaging unit, used to package the target transaction data to be packaged into a second block; and a second block broadcasting unit, used to broadcast the second block to the blockchain network.
[0017] The present disclosure provides an electronic device comprising: at least one processor; and a storage device for storing at least one program. When the at least one program is executed by the at least one processor, the at least one processor implements the blockchain-based data processing method as described in the above embodiments.
[0018] The embodiments of the present disclosure provide a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the blockchain-based data processing method as described in the above embodiments.
[0019] According to one aspect of the present application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the blockchain-based data processing method provided in the various optional implementations described above.
[0020] In the technical solutions provided in some embodiments of the present disclosure, when the accounting node in the blockchain network packages the current first block, compared with the to-be-packaged transaction data with a lower packaging priority in the transaction pool of the blockchain network, the internal transaction data generated by triggering the first smart contract deployed in the blockchain network is obtained first, and the internal transaction data is packaged into the first block. This can achieve the goal of packaging internal transaction data with a high packaging priority into the first block first, and the internal transaction data is obtained by triggering the first smart contract deployed in the blockchain network, thereby ensuring that the triggering of the first smart contract meets the timeliness.
[0021] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification, are used to explain the principles of the present disclosure. Obviously, the drawings described below are only some embodiments of the present disclosure, and those skilled in the art can derive other drawings based on these drawings without inventive effort.
[0023] Figure 1 This is an optional structural diagram of the distributed system 100 provided in the embodiment of the present disclosure applied to a blockchain system.
[0024] Figure 2 This is an optional schematic diagram of the block structure provided by the embodiment of the present disclosure.
[0025] Figure 3 The figure schematically shows a flowchart of a blockchain-based data processing method according to an embodiment of the present disclosure.
[0026] Figure 4 The figure schematically shows a flowchart of a blockchain-based data processing method according to another embodiment of the present disclosure.
[0027] Figure 5 The figure schematically shows a flowchart of a blockchain-based data processing method according to another embodiment of the present disclosure.
[0028] Figure 6 The figure schematically shows a structural diagram of a first block header according to an embodiment of the present disclosure.
[0029] Figure 7 The figure schematically shows a flowchart of a blockchain-based data processing method according to an embodiment of the present disclosure.
[0030] Figure 8 The figure schematically shows a flowchart of a blockchain-based data processing method according to an embodiment of the present disclosure.
[0031] Figure 9 The figure schematically shows a flowchart of a blockchain-based data processing method according to an embodiment of the present disclosure.
[0032] Figure 10 The figure schematically shows a flowchart of a blockchain-based data processing method according to an embodiment of the present disclosure.
[0033] Figure 11 The figure schematically shows a data processing method based on blockchain according to an embodiment of the present disclosure.
[0034] Figure 12 The figure schematically shows a block diagram of a blockchain-based data processing device according to an embodiment of the present disclosure.
[0035] Figure 13 A schematic structural diagram of an electronic device suitable for implementing the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0036] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete and will fully convey the concepts of the example embodiments to those skilled in the art.
[0037] In addition, the described features, structures or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, well-known methods, devices, implementations or operations are not shown or described in detail to avoid blurring various aspects of the present disclosure.
[0038] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically separate entities. In other words, these functional entities may be implemented in software, in at least one hardware module or integrated circuit, or in different networks and / or processor devices and / or microcontroller devices.
[0039] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, while others may be combined or partially combined. Therefore, the actual execution order may vary depending on the actual situation.
[0040] The embodiments of the present disclosure are applied to blockchain technology. For example, the system involved in the embodiments of the present disclosure can be a distributed system formed by connecting a client and multiple nodes (any form of computing device connected to the network, such as a server or user terminal) through network communication.
[0041] Taking the distributed system as the blockchain system as an example, see Figure 1 , Figure 1 This is an optional structural diagram of a distributed system provided by an embodiment of the present disclosure applied to a blockchain system. The distributed system 100 is composed of multiple nodes 110 (any form of computing device connected to the network, such as a server or user terminal) and clients 120. The nodes form a peer-to-peer (P2P) network. The P2P protocol is an application layer protocol that runs on top of the Transmission Control Protocol (TCP). In a distributed system, any machine, such as a server or terminal, can join and become a node. A node includes a hardware layer, an intermediate layer, an operating system layer, and an application layer.
[0042] See also Figure 1 The functions of each node in the blockchain system shown include:
[0043] 1) Routing: A basic function of a node, used to support communication between nodes.
[0044] In addition to the routing function, nodes can also have the following functions:
[0045] 2) Applications are deployed within the blockchain to implement specific services based on actual business needs. They record data related to these functions, such as transaction data in virtual online trading systems and accounting systems. The recorded data carries a digital signature to indicate the source of the task data. The recorded data is then sent to other nodes in the blockchain system. Once the other nodes have successfully verified the source and integrity of the recorded data, they add the recorded data to a temporary block.
[0046] For example, the services implemented by the application include:
[0047] 2.1) Wallet: This is used to provide the functionality for conducting electronic resource transactions, including initiating transactions (i.e., sending the transaction record of the current transaction to other nodes in the blockchain system. After successful verification by other nodes, the transaction record data is placed in the transaction pool as a response to acknowledge the validity of the transaction and stored in a temporary block of the blockchain). Of course, the wallet also supports querying the remaining electronic resources in the electronic resource address.
[0048] 2.2) Smart contracts are computerized protocols that can execute the terms of a contract. They are implemented through code deployed on a shared ledger that is executed when certain conditions are met. Based on actual business needs, the code is used to complete automated transactions, such as querying the logistics status of a buyer's purchased goods and transferring the buyer's electronic resources to the merchant's address after the buyer signs for the goods. Of course, smart contracts are not limited to executing contracts for transactions, but can also execute contracts that process received information.
[0049] 3) Blockchain, including a series of blocks that are connected to each other in the order of their generation. Once a new block is added to the blockchain, it will not be removed. The block records the record data of online transactions submitted by the nodes in the blockchain system.
[0050] See also Figure 2 , Figure 2This is an optional schematic diagram of the block structure provided by the embodiments of the present disclosure. Each block includes the hash value of the transaction records stored in the block (the hash value of the current block) and the hash value of the previous block. The blocks are connected by hash values to form a blockchain. In addition, the block may also include information such as the timestamp when the block was generated. Blockchain is essentially a decentralized database, a series of data blocks generated using cryptographic methods. Each data block contains relevant information used to verify the validity of the information (anti-counterfeiting) and generate the next block.
[0051] Figure 3 The flowchart of the data processing method based on blockchain according to an embodiment of the present disclosure is schematically shown. The method provided by the embodiment of the present disclosure can be processed by any electronic device with computing processing capabilities, such as the above Figure 1 Any node 110 in the embodiment may include a bookkeeping node in a blockchain network. In the following example, the bookkeeping node in the blockchain network is used as an example to execute the provided method, but the present disclosure is not limited to this.
[0052] In the disclosed embodiments, a bookkeeping node refers to a node in a blockchain network that can be used to package and generate new blocks and has a consensus function. Any node other than a bookkeeping node in a blockchain network is referred to as a non-bookkeeping node.
[0053] Figure 3 In an embodiment, a first smart contract is deployed in a blockchain network.
[0054] In practical applications, public, private, and consortium blockchains can all provide smart contract functionality. Smart contracts on the blockchain are contracts that can be triggered and executed by transactions on the blockchain. Smart contracts can be defined in code.
[0055] Taking Ethereum as an example, users can create and invoke complex logic within the Ethereum network. As a programmable blockchain, Ethereum's core is the Ethereum Virtual Machine (EVM), which runs on every Ethereum node. The EVM is a Turing-complete virtual machine that enables the implementation of complex logic. When users publish and invoke smart contracts within Ethereum, they execute them on the EVM. In reality, the EVM directly runs virtual machine code (bytecode), so smart contracts deployed on the blockchain can be written in bytecode.
[0056] In the disclosed embodiments, at least one smart contract can be deployed on a blockchain network, each of which includes contract code corresponding to the business logic. The at least one smart contract includes a first smart contract. The first smart contract may be a smart contract whose internal transaction data, when triggered, needs to be prioritized by the accounting node for packaging. It may also include smart contracts that are time-sensitive when triggered for execution. For example, a smart contract that is triggered at 5:00 p.m. every day to enable invoice circulation may be implemented. Another example is a smart contract that is triggered when the block height is an integer multiple of 1000 to enable lottery draws. The block number in the blockchain is the block height.
[0057] Any smart contract in the embodiments of the present disclosure can be deployed on the blockchain network in the following manner, but the present disclosure is not limited thereto. After a user sends a transaction containing the creation of a smart contract to the blockchain network, each node can execute the transaction in the EVM. Among them, the From field in the transaction is used to record the address of the account that initiated the creation of the smart contract, the contract code stored in the field value of the Data field of the transaction can be bytecode, and the field value of the To field of the transaction is a null account. When the nodes reach an agreement through the consensus mechanism, the smart contract is successfully created, and subsequent users can call this smart contract.
[0058] After each smart contract is created, a corresponding contract account appears on the blockchain with a specific address. The contract code is stored in the account storage of that contract account. The smart contract's behavior is controlled by the contract code, while the smart contract's account storage stores the contract's state. In other words, a smart contract creates a virtual account on the blockchain that contains the contract code and account storage. A smart contract can declare various members, including state variables, functions, function modifiers, and events. State variables are values permanently stored in the smart contract's account storage field and are used to maintain the smart contract's state.
[0059] Figure 3 In an embodiment, the blockchain network may include a transaction pool, which may include transaction data to be packaged.
[0060] Among them, the transaction pool can be used to store transaction data to be packaged, and the transaction data to be packaged is waiting to be selected by the accounting node and then packaged into the block. The transaction data to be packaged in the embodiment of the present disclosure may include transactions executed by the accounting node after being packaged into the block, and may also include transactions executed by any other electronic device after being packaged into the block by the accounting node (for example, executed by a non-accounting node, or executed by other terminals or servers outside the blockchain network), and may also include transaction data generated after the transaction is executed (the execution subject may be any node in the blockchain network, or other terminals or servers outside the blockchain network). This disclosure does not limit this. In addition, the embodiment of the present disclosure does not limit the source of the transaction data to be packaged in the transaction pool.
[0061] like Figure 3 As shown, the blockchain-based data processing method provided by the embodiment of the present disclosure may include the following steps.
[0062] In step S310, internal transaction data is obtained, wherein the internal transaction data is obtained by triggering the first smart contract, and the packaging priority of the internal transaction data is higher than at least part of the transaction data to be packaged.
[0063] Among them, internal transaction data refers to transaction data generated by triggering the execution of a time-sensitive first smart contract. In order to meet the timeliness when the first smart contract is triggered, the packaging priority of the internal transaction data can be set to be higher than at least part of the transaction data to be packaged in the transaction pool. Here, the packaging priority of the internal transaction data is higher than at least part of the transaction data to be packaged in the transaction pool. This means that when the accounting node is preparing to package the current latest block, if there is internal transaction data, it will be packaged first. If the size of the internal transaction data is smaller than the preset size of the latest block, it can select a portion of the transaction data to be packaged from the transaction pool as the target transaction data to be packaged, and package it together with the internal transaction data into the current latest block; if the size of the internal transaction data is already equal to the preset size of the latest block, it can also be currently packaged only into the latest block. By giving the internal transaction data a higher packaging priority than at least part of the transaction data to be packaged in the transaction pool, it can be ensured that the internal transaction data is packaged into the current latest block first, thereby meeting the timeliness when the first smart contract is triggered.
[0064] In step S320, the internal transaction data is packaged to generate a first block.
[0065] In the disclosed embodiment, the first block may be the latest block to be generated by the accounting node at the current time. The accounting node may prioritize packaging internal transaction data into the first block.
[0066] In step S330, the first block is broadcast to the blockchain network.
[0067] In the disclosed embodiment, a ledger node broadcasts a first block to other nodes in a blockchain network so that the other nodes in the blockchain network can reach consensus on the first block. In the disclosed embodiment, the first block may include a first block header and a first block body. Broadcasting the first block to the blockchain network may include broadcasting both the first block header and the first block body, or may include broadcasting only the first block header, which is not limited in the disclosed embodiment.
[0068] Among them, the consensus algorithms supported in the blockchain may include:
[0069] The first type of consensus algorithm involves nodes competing for the right to record transactions during each accounting cycle. Examples include Proof of Work (POW), Proof of Stake (POS), and Delegated Proof of Stake (DPOS). In a blockchain network employing this type of consensus algorithm, all nodes competing for record-keeping rights can execute transactions upon receiving them. Among the competing nodes, one may emerge victorious in this round and become the record-keeping node. Record-keeping nodes can package internal transactions (or internal transaction data) with target transaction data selected from other transaction pools to generate a new block. These nodes then send the generated new block, or its header, to other nodes for consensus.
[0070] The second type of consensus algorithm pre-selects accounting nodes for each accounting round (without requiring a contest for accounting rights). Examples include consensus algorithms like Practical Byzantine Fault Tolerance (PBFT). In blockchain networks using this type of consensus algorithm, the nodes with accounting rights are already determined before the current accounting round. Therefore, after receiving a transaction (or transaction data, which may include internal transactions, internal transaction data, and pending transaction data), if the node is not the accounting node for the current round, it can send the transaction (or transaction data) to the accounting node. The accounting node for the current round can execute the internal transaction (or internal transaction data) and the transactions in the target pending transaction data before or during the process of packaging the internal transaction (or internal transaction data) with the target pending transaction data selected from other transaction pools to generate the latest block. After generating the latest block, the accounting node can send the latest block or its block header to other nodes for consensus.
[0071] In the disclosed embodiments, the consensus algorithm used by the blockchain is not limited. Each accounting node in this round can package the received transactions (or transaction data) to generate a new block and send the generated new block or the block header of the new block to other nodes for consensus verification. If other nodes receive the new block or the block header of the new block and verify that there are no problems, they can append the new block to the end of the original blockchain, thereby completing the blockchain accounting process. While other nodes are verifying the new block or block header sent by the accounting node, they can also execute the transactions contained in the new block.
[0072] The blockchain-based data processing method provided by the embodiments of the present disclosure prioritizes obtaining internal transaction data generated by triggering a first smart contract deployed in the blockchain network when the accounting node in the blockchain network packages the current first block, compared to transaction data to be packaged with a lower packaging priority in the transaction pool of the blockchain network. The internal transaction data is packaged into the first block. This enables internal transaction data with a high packaging priority to be packaged into the first block first, and the internal transaction data is obtained by triggering the first smart contract deployed in the blockchain network, thereby ensuring that the triggering of the first smart contract meets the timeliness.
[0073] Figure 4 A flowchart schematically illustrates a blockchain-based data processing method according to another embodiment of the present disclosure. In this embodiment, a second smart contract is also deployed in the blockchain network. The second smart contract is a system-level smart contract deployed in the blockchain network. The contract code included in the second smart contract can be used to determine whether the triggering conditions of the first smart contract are met. If the triggering conditions of the first smart contract are determined to be met, the second smart contract can also be called or triggered.
[0074] Figure 4 Embodiment and above Figure 3 The difference between the embodiments is that the above step S310 may further include the following steps.
[0075] In step S311, the second smart contract is called.
[0076] In the embodiment of the present disclosure, it can be configured that before the accounting node packages the latest block each time, the second smart contract deployed in the blockchain network is called first.
[0077] In step S312, the second smart contract is used to determine whether the triggering condition of the first smart contract is met.
[0078] In the disclosed embodiment, the second smart contract may include a pre-set trigger condition function (can_invoke function). The trigger condition of the first smart contract may be pre-set in the can_invoke function, and the accounting node can determine whether the trigger condition of the first smart contract is currently met by calling the can_invoke function.
[0079] It should be noted that the embodiments of the present disclosure are not limited to determining whether the triggering condition of the first smart contract is met by a triggering condition function. As long as the contract code in the second smart contract can implement the determination of the triggering condition of the first smart contract, the specific form is not limited.
[0080] Specifically, the information used to determine whether the triggering condition of the first smart contract is currently met can be configured accordingly based on the specific first smart contract, and this disclosure does not limit this. The second smart contract can synchronize the blockchain status to obtain the required information. For example, if the triggering condition of the first smart contract is that the latest block height in the blockchain is an integer multiple of 1000, the second smart contract obtains the current block height and determines whether the current block height is an integer multiple of 1000 to determine whether the triggering condition of the first smart contract is met.
[0081] In the disclosed embodiments, if a second smart contract needs to obtain information from outside the blockchain network to determine whether the triggering conditions of the first smart contract are met, the second smart contract deployed on the blockchain network can use an oracle to obtain external data from data entities outside the blockchain network. For example, if the triggering condition of the first smart contract is to trigger at 5:00 PM every day, the external data obtained by the second smart contract can be the current time. By determining whether the current time is 5:00 PM, it can determine whether the triggering conditions of the first smart contract are met. Data entities outside the blockchain network may include servers, data centers, or terminals deployed outside the blockchain network. Oracles can be used to connect the blockchain network with data entities outside the blockchain, enabling data interaction between the blockchain network and the real world.
[0082] In practical applications, when deploying an oracle for a second smart contract on a blockchain network, an oracle smart contract corresponding to the oracle can be deployed on the blockchain network. This oracle smart contract is used to maintain the external data sent by the oracle to the second smart contract on the blockchain network. For example, the external data sent by the oracle to the second smart contract on the blockchain network can be stored in the account storage space of the oracle smart contract.
[0083] When the accounting node calls the can_invoke function of the second smart contract, it can read the external data required by the second smart contract from the account storage space of the oracle smart contract to complete the judgment of the triggering conditions of the first smart contract.
[0084] It should be noted that when the oracle sends external data to the second smart contract on the blockchain network, it can use either active or passive sending methods.
[0085] In some embodiments, the off-chain data entity can sign the external data that needs to be provided to the second smart contract using the oracle's private key and send it to the oracle smart contract. For example, when the external data is the current time, the signed external data can be sent to the oracle smart contract in a periodic manner. The oracle's CA certificate can be maintained in the oracle smart contract. After receiving the external data sent by the off-chain data entity, the oracle's public key maintained in the CA certificate can be used to verify the signature of the external data. After the verification is passed, the external data sent by the off-chain data entity is stored in the account storage space of the oracle smart contract.
[0086] In other embodiments, when the can_invoke function of the second smart contract on the blockchain network is called, if the external data required by the second smart contract is not read from the account storage space of the oracle smart contract, the oracle smart contract can use the event mechanism of the smart contract to interact with the above-mentioned oracle, and the above-mentioned oracle will send the external data required by the second smart contract to the account storage space of the oracle smart contract.
[0087] In step S313, the execution of the first smart contract is triggered by the second smart contract to generate internal transaction data.
[0088] In the disclosed embodiments, the second smart contract may further include contract code for triggering the execution of the first smart contract, such as the action function (invoke function) mentioned below. For example, if the accounting node calls the can_invoke function in the second smart contract and determines that the triggering conditions of the first smart contract are met, it may further call the invoke function in the second smart contract to trigger the execution of the first smart contract and generate internal transaction data.
[0089] In the blockchain world, there's a concept called an account. Taking Ethereum as an example, accounts are categorized into two types: external accounts and contract accounts. External accounts are accounts directly controlled by users, also known as user accounts. Contract accounts are accounts created by users through external accounts and contain contract code (i.e., smart contracts). Of course, other account types are also possible, and this disclosure does not limit them.
[0090] In the following embodiments, serialized cryptographically signed instructions generated by externally owned user accounts and submitted to the blockchain network are referred to as transactions or transaction data. These transactions or transaction data are placed in a transaction pool as pending transaction data. The pending transaction data may include the following components: Nonce: a count of the number of transactions or transaction data sent by the sender; gasPrice: the number of Wei (electronic resource units) per unit of gas the sender is willing to pay to execute the transaction; gasLimit: the maximum amount of gas the sender is willing to pay to execute the transaction; to: the address of the recipient. In a contract creation transaction, the contract account address does not yet exist, so a null value is used; Value: the amount transferred from the sender to the recipient. In a contract creation transaction, this Value serves as the starting balance in the newly created contract account; v, r, s: used to generate a signature identifying the sender of the transaction; Init (only present in a contract creation transaction): an EVM code snippet used to initialize the new contract account; data (an optional field only present in a message call): the input data (i.e., parameters) of the message call. For example, if a first smart contract acts as a domain name registration service, then a call to the first smart contract may have input fields such as a domain name and an IP (Internet Protocol) address.
[0091] One difference between the internal transaction data and the transaction data to be packaged in the disclosed embodiment is that the internal transaction data is not generated by an external account, but is generated by the second smart contract triggering the first smart contract. The internal transaction data may not include the gasLimit.
[0092] In an exemplary embodiment, a second smart contract may be deployed in the blockchain network, and the blockchain network may further include a non-accounting node. Acquiring internal transaction data may include: receiving the internal transaction data from the non-accounting node; wherein the non-accounting node is configured to invoke the second smart contract, determine through the second smart contract whether a triggering condition of the first smart contract is satisfied, trigger the execution of the first smart contract using the second smart contract, and generate and broadcast the internal transaction data.
[0093] exist Figure 4In the embodiment, the accounting node is set to call the second smart contract first when packaging the latest block, and judge whether the trigger condition of the first smart contract is met through the second smart contract. When the trigger condition of the first smart contract is met, the second smart contract triggers the execution of the first smart contract. Thus, the accounting node can directly obtain the internal transaction data locally, ensuring the reliability of obtaining the internal transaction data first, and will not be affected by the instability of the blockchain network. However, the present disclosure is not limited to this. In other embodiments, any node in the blockchain network, such as a non-accounting node, can also call the second smart contract, and judge whether the trigger condition of the first smart contract is met through the second smart contract. When the trigger condition of the first smart contract is met, the second smart contract triggers the execution of the first smart contract. When the non-accounting node generates internal transaction data, it broadcasts the internal transaction data to the blockchain network, and the accounting node can obtain the internal transaction data. After the accounting node obtains the internal transaction data, it will give priority to packaging the received internal transaction data into the latest block compared to the transaction data to be packaged in the transaction pool. This can reduce the computational load of the accounting node and help improve the packaging efficiency of the accounting node. In the following embodiments, the example of the accounting node calling the second smart contract is used for illustration.
[0094] In an exemplary embodiment, the second smart contract may include an action function. The method of triggering the execution of the first smart contract through the second smart contract to generate the internal transaction data may include: calling the action function to trigger the first smart contract to generate the internal transaction data. The method may further include: selecting target transaction data to be packaged from the transaction data to be packaged in the transaction pool; and packaging the target transaction data to be packaged into the first block. For details, please refer to Figure 5 Example.
[0095] Figure 5 The figure schematically shows a flowchart of a blockchain-based data processing method according to another embodiment of the present disclosure. Figure 5 The method provided in the embodiment may include the following steps.
[0096] In step S501, the second smart contract is called.
[0097] In step S502, the second smart contract is used to determine whether the triggering condition of the first smart contract is met.
[0098] Steps S501 and S502 can refer to the above Figure 4 Steps S311 and S312 in the embodiment.
[0099] In step S503, the action function in the second smart contract is called to trigger the first smart contract and generate internal transaction data.
[0100] Figure 5 In this embodiment, when the accounting node determines that the triggering conditions of the first smart contract are met through the can_invoke function in the second smart contract, it directly calls the invoke function in the second smart contract to trigger the first smart contract and generate internal transaction data.
[0101] For example, assuming that the first smart contract triggers the lottery when the current block height is an integer multiple of 1000, then when the second smart contract finds that the current block height is 2000, it triggers the first smart contract. Assuming that user A wins 15 units of electronic resources, 15 units of electronic resources will be transferred to user A's account.
[0102] In the disclosed embodiments, whether it is an external account or a contract account, the account status may include fields such as Balance, Nonce, Code, and Storage. The Nonce field is used to maintain the number of transactions for the account. It is a counter used to ensure that each transaction can and can only be processed once. If the account is an external account, this number represents the number of transactions sent from the account address. If the account is a contract account, the Nonce is the number of contracts created by the account. The Balance field is used to maintain the current account balance of the account, which can be the number of Wei owned by this address. The Storage field is used to maintain the storage content of the account (the default field value is empty). For contract accounts, an independent storage space is usually allocated to store the storage content of the contract account. This independent storage space is called the account storage of the contract account. The storage content of the contract account can be constructed into an MPT (Merkle Patricia Trie) tree data structure and stored in the above-mentioned independent storage space. The MPT tree constructed based on the storage content of the contract account can be called a Storage tree. The Storage field can only maintain the root node of the Storage tree. Therefore, the Storage field can also be called the StorageRoot field. StorageRoot is the hash of the root node of a Merkle Patricia tree. It encodes the hash value of the account's storage content and defaults to empty. For external accounts, the Storage field is empty. The Code field is used to maintain the contract code of the account. In practical applications, the Code field can only maintain the hash value of the contract code. Therefore, the Code field can also be called the Codehash field. The Codehash field is the hash value code of the EVM. For contract accounts, this is a code that is hashed and stored as codeHash; for external accounts, the codeHash field is the hash of an empty string.
[0103] Taking Ethereum as an example, the global state of Ethereum consists of a mapping between account addresses and account states. This mapping is stored in a data structure called a state tree (which can be an MPT tree). The state tree is a binary structure consisting of a set of tree-like nodes. It includes: a large number of leaf nodes at the bottom layer, which contain potential data; a set of intermediate nodes, each of which is the hash of its two child nodes; and a single root node, also formed by the hash of its two child nodes, representing the top of the tree, called the state root. In Ethereum, the key-value pairs of the state tree are mappings between account addresses and related accounts, including fields such as Balance, Nonce, Codehash, and StorageRoot for each account.
[0104] Taking the above lottery as an example, after 15 units of electronic resources are transferred to user A's account, the balance of user A's user account increases by 15 units of electronic resources, which will cause the state tree to change. Let's call it the first state tree, and the root node of the first state tree is called the first state root.
[0105] In step S504, target transaction data to be packaged is selected from the transaction data to be packaged in the transaction pool.
[0106] In the disclosed embodiment, the accounting node may select the transaction data to be packaged in the transaction pool according to a predetermined selection rule. The selected transaction data to be packaged is referred to as the target transaction data to be packaged. The predetermined selection rule is not limited to, for example, the value of the electronic resource based on the reward.
[0107] In step S505 , the internal transaction data and the target transaction data to be packaged are packaged to generate a first block.
[0108] Figure 5 In an embodiment, the target transaction data to be packaged may include a first state root. If the target transaction data to be packaged in the first block does not include transactions that need to be executed by the accounting node, the first state root may be packaged into the first block header of the first block. If the target transaction data to be packaged in the first block includes transactions that need to be executed by the accounting node, the accounting node may update the blockchain network state, such as the account state, when executing these transactions, that is, update the above-mentioned first state tree to generate a second state tree. The root node of the second state tree is called the second state root. At this time, the first block header of the first block stores the second state root updated based on the first state tree. The structure of the first block header can be seen below. Figure 6 Description of embodiments.
[0109] For example, assuming that the target transaction data to be packaged includes user B transferring 100 units of electronic resources to user A, after the accounting node triggers the execution of the corresponding smart contract, the account balance of user A increases by 115 units of electronic resources, that is, at this time it is necessary to update the first state tree to generate the second state tree.
[0110] In step S506, the first block is broadcast to the blockchain network.
[0111] Step S506 can refer to the above Figure 3 Step S330 in the embodiment.
[0112] Figure 5In this embodiment, the accounting node is configured to preferentially call the can_invoke function in the second smart contract each time the latest block is packaged to determine whether the triggering conditions of the first smart contract are met. If the triggering conditions of the first smart contract are determined to be met, the invoke function in the second smart contract is directly called to trigger the execution of the first smart contract to generate internal transaction data, such as updating the account status and generating the first state tree and its first state root. This ensures the timeliness of the triggering of the first smart contract, so that the triggering conditions of the first smart contract are still met when the first smart contract is triggered. After this, based on the first state tree and its first state root, the accounting node can select the target transaction data to be packaged from the transaction pool and put it into the latest block, and then reach consensus on the latest block and upload it to the chain.
[0113] Figure 6 The figure schematically shows a structural diagram of a first block header according to an embodiment of the present disclosure.
[0114] like Figure 6 As shown, the first block header may include the parent block hash value (parentHash), timestamp (timestamp) and state root (stateRoot, which may include the first state root or the second state root mentioned above). The state root corresponds to the state tree. Furthermore, the same tree structure can also be used to store transactions (or transaction data) and receipts. Therefore, the first block can store the hashes of three different Merkle tree structure root nodes, including the state tree, transaction tree and receipt tree. The corresponding first block header may also include Figure 6 transactionsRoot and receiptsRoot are not shown.
[0115] The state tree is an MPT tree composed of the state data of all accounts in the blockchain; the transaction tree is an MPT tree composed of transaction data in the blockchain; and the receipt tree is an MPT tree composed of the transaction receipts generated after the transactions in the block are executed. The hash values of the root nodes of the state tree, transaction tree, and receipt tree are respectively the state root, transaction root, and receipt root, and are ultimately added to the first block header of the first block.
[0116] The transaction tree and receipt tree both correspond to blocks, meaning each block has its own transaction tree and receipt tree. The state tree, on the other hand, is a global MPT tree that doesn't correspond to a specific block, but rather encompasses the account state data of all accounts in the blockchain.
[0117] For accounts in the blockchain, Figure 6The structure shown in Figure 1 is used to maintain the account status of the account. When the transaction in the first block is executed, the status of the account related to the transaction in the blockchain (which can be an external account or a contract account) will usually change accordingly.
[0118] For example, when a "transfer transaction" in the first block is executed, the balances of the transferor and transferee accounts associated with the transfer transaction (i.e., the values of the Balance fields of these accounts) will also change. After the transaction in the first block generated by the blockchain is executed, since the account status in the current blockchain has changed, the node needs to construct a first state tree or a second state tree based on the current account status data of all accounts in the blockchain to maintain the latest status of all accounts in the blockchain. In other words, every time a new block is generated in the blockchain and the transactions in that new block are executed, resulting in a change in the account status in the blockchain, the node reconstructs an MPT state tree based on the latest account status data of all accounts in the blockchain. In other words, each block in the blockchain has a corresponding MPT state tree; this MPT state tree maintains the latest account status of all accounts in the blockchain after the transactions in that block are executed.
[0119] After the accounting node broadcasts the first block to other nodes in the blockchain network, the other nodes are also set to prioritize calling the second smart contract, triggering the execution of the first smart contract, generating internal transaction data, and then executing the transactions (if any) in the target to-be-packaged transaction data in the first block. In this way, if a node does not prioritize calling the second smart contract to trigger the execution of the first smart contract, the state root (first state root or second state root) generated by the node after executing the transactions in the first block will be inconsistent with the state root in the first block header of the first block sent by the accounting node. From this, it can be known that the node did not prioritize calling the second smart contract to trigger the execution of the first smart contract. If the node receiving the first block prioritizes calling the second smart contract to trigger the first smart contract, and then executes the transactions in the first block, the generated state root will be consistent with the state root in the received first block header, which can be verified and the first block can be put on the chain after consensus is reached.
[0120] For example, if a node does not trigger the first smart contract for the lottery, it will not record the transfer of 15 units of electronic resources from user A, but only record the transfer of 100 units of electronic resources from user B to user A in the target transaction data to be packaged, which ultimately leads to the state root generated by the node being inconsistent with the state root in the first block header of the first block.
[0121] In an exemplary embodiment, the second smart contract may include an action function. The second smart contract triggers the execution of the first smart contract to generate the internal transaction data, which may include: generating an internal transaction according to the action function and the first smart contract; packaging the internal transaction into the first block; selecting target transaction data to be packaged from the transaction data to be packaged in the transaction pool; packaging the target transaction data to be packaged into the first block; executing the internal transaction in the first block to trigger the first smart contract to generate the internal transaction data. For details, please refer to the following Figure 7 Description of embodiments.
[0122] Figure 7 The figure schematically shows a flowchart of a blockchain-based data processing method according to an embodiment of the present disclosure. Figure 7 The method provided in the embodiment may include the following steps.
[0123] In step S701, the second smart contract is called.
[0124] In step S702, the second smart contract is used to determine whether the triggering condition of the first smart contract is met.
[0125] Steps S701 and S702 can refer to the above Figure 4 Steps S311 and S312 in the embodiment.
[0126] In step S703, an internal transaction is generated based on the action function in the second smart contract and the first smart contract.
[0127] In the disclosed embodiment, an internal transaction may be an instruction or message initiated by a contract account (e.g., the account corresponding to the second smart contract below) to another contract account (e.g., the account corresponding to the first smart contract above) to trigger the execution of the smart contract corresponding to the other contract account (e.g., the first smart contract); or an instruction or message generated by a contract account (e.g., the account corresponding to the second smart contract below) based on another contract account (e.g., the account corresponding to the first smart contract above), which may trigger the smart contract corresponding to the other contract account (e.g., the first smart contract) when the instruction or message is packaged into a block and executed.
[0128] For example, assuming that the first smart contract is a lottery contract whose trigger condition is that the current block height is an integer multiple of 1000, marked as "A", then according to the action function invoke in the second smart contract, an instruction called invoke(A) can be generated, and this instruction is used as an internal transaction.
[0129] In step S704, the internal transaction is packaged into the first block.
[0130] In the disclosed embodiment, internal transactions are prioritized over at least some of the pending transaction data in the transaction pool. Therefore, when a bookkeeping node is packaging the latest first block, if it detects an internal transaction, it will prioritize packaging that internal transaction into the first block.
[0131] In step S705 , target transaction data to be packaged is selected from the transaction data to be packaged in the transaction pool.
[0132] Figure 7 In the embodiment, assuming that the size of the internal transaction has not yet filled up the size of the first block, the accounting node may continue to select part of the transaction data to be packaged from the transaction pool as the target transaction data to be packaged.
[0133] In step S706 , the target transaction data to be packaged is packaged into the first block.
[0134] The accounting node then packages the target transaction data to be packaged into the first block.
[0135] In step S707, the internal transaction in the first block is executed to trigger the first smart contract to generate internal transaction data.
[0136] After the accounting node generates the first block, it executes the internal transactions in the first block. For example, it executes the invoke(A) instruction to generate corresponding internal transaction data, which is then recorded in the first block.
[0137] In step S708, the first block is broadcast to the blockchain network.
[0138] Step S708 can refer to the above Figure 3 Step S330 in the embodiment.
[0139] Figure 7 In an embodiment, when packaging the latest block, the accounting node is set to give priority to calling the can_invoke function in the second smart contract. When it is determined that the trigger condition of the first smart contract is met, the first smart contract is not triggered immediately. Instead, an internal transaction is first generated according to the invoke function in the second smart contract and the first smart contract, and the internal transaction is preferentially packaged into the latest block. The target transaction data to be packaged can continue to be selected from the transaction pool and packaged into the latest block. After the latest block is packaged, the accounting node executes the internal transaction and triggers the first smart contract to generate internal transaction data. This can also ensure that the internal transaction is selected first, that is, the timeliness of the triggering of the first smart contract is guaranteed.
[0140] In an exemplary embodiment, the second smart contract may include an action function. The second smart contract triggers the execution of the first smart contract to generate the internal transaction data, which may include: generating an internal transaction based on the action function and the first smart contract; and triggering the first smart contract to generate the internal transaction data during the process of packaging the internal transaction into the first block. Figure 8 Description of embodiments.
[0141] Figure 8 The figure schematically shows a flowchart of a blockchain-based data processing method according to an embodiment of the present disclosure. Figure 8 The method provided in the embodiment may include the following steps.
[0142] In step S801, the second smart contract is called.
[0143] In step S802, the second smart contract is used to determine whether the triggering condition of the first smart contract is met.
[0144] Steps S801 and S802 can refer to the above Figure 4 Steps S311 and S312 in the embodiment.
[0145] In step S803, an internal transaction is generated based on the action function in the second smart contract and the first smart contract.
[0146] Step S803 can refer to the above Figure 7 Step S703 in the embodiment.
[0147] In step S804, during the process of packaging the internal transaction into the first block, the first smart contract is triggered to generate internal transaction data.
[0148] Optionally, in step S805 , target transaction data to be packaged is selected from the transaction data to be packaged in the transaction pool.
[0149] Optionally, in step S806 , the target transaction data to be packaged is packaged into the first block.
[0150] Steps S805 and S806 can refer to the above Figure 7 Steps S705 and S706 in the embodiment.
[0151] In step S807, the first block is broadcast to the blockchain network.
[0152] Step S807 can refer to the above Figure 3 Step S330 in the embodiment.
[0153] Figure 8In an embodiment, when packaging the latest block, the accounting node is set to preferentially call the can_invoke function in the second smart contract. When it is determined that the triggering condition of the first smart contract is met, the first smart contract is not triggered immediately. Instead, an internal transaction is first generated according to the invoke function in the second smart contract and the first smart contract, and the internal transaction is preferentially packaged into the latest block. At the same time, in the process of packaging the internal transaction into the latest block, the accounting node can execute the internal transaction and trigger the first smart contract to generate internal transaction data, thereby ensuring the timeliness of the triggering of the first smart contract, that is, there is no need to wait until the first block is packaged before executing the internal transaction.
[0154] In an exemplary embodiment, the second smart contract may include an action function. The second smart contract triggers the execution of the first smart contract to generate the internal transaction data, which may include: generating an internal transaction according to the action function and the first smart contract; placing the internal transaction into the transaction pool; selecting the internal transaction and the target transaction data to be packaged from the transaction pool; packaging the internal transaction and the target transaction data to be packaged into the first block; executing the internal transaction in the first block, triggering the first smart contract, and generating the internal transaction data. For details, please refer to the following Figure 9 Description of embodiments.
[0155] Figure 9 The figure schematically shows a flowchart of a blockchain-based data processing method according to an embodiment of the present disclosure. Figure 9 The method provided in the embodiment may include the following steps.
[0156] In step S901, the second smart contract is called.
[0157] In step S902, the second smart contract is used to determine whether the triggering condition of the first smart contract is met.
[0158] Steps S901 and S902 can refer to the above Figure 4 Steps S311 and S312 in the embodiment.
[0159] In step S903, an internal transaction is generated based on the action function in the second smart contract and the first smart contract.
[0160] Step S903 can refer to the above Figure 7 Step S703 in the embodiment.
[0161] In step S904, the internal transaction is placed in the transaction pool.
[0162] In the embodiment of the present disclosure, when the accounting node puts the internal transaction into the transaction pool, it can add an identifier to the internal transaction (the present disclosure does not limit the specific form of the identifier). The identifier can be used to indicate that the packaging priority of the internal transaction is higher than other transaction data to be packaged in the transaction pool, so as to ensure that the internal transaction can be preferentially selected from the transaction pool.
[0163] In step S905 , target transaction data to be packaged is selected from the internal transaction and transaction data to be packaged from the transaction pool.
[0164] When packaging the latest block, the accounting node first determines whether there is an internal transaction with a high packaging priority in the transaction pool. If so, it will be selected from the transaction pool first. Then, the remaining transaction data to be packaged will be selected as the target transaction data to be packaged.
[0165] In step S906, the internal transaction data and the target transaction data to be packaged are packaged to generate a first block.
[0166] In step S907, the internal transaction in the first block is executed, the first smart contract is triggered, and the internal transaction data is generated.
[0167] It is understandable that although Figure 9 The embodiment takes the execution of the internal transaction in the first block after the first block is generated as an example, but the present disclosure is not limited to this. The accounting node can also preferentially select the internal transaction from the transaction pool and execute the internal transaction simultaneously during the packaging process.
[0168] In step S908, the first block is broadcast to the blockchain network.
[0169] Step S908 can refer to the above Figure 3 Step S330 in the embodiment.
[0170] Figure 9 In an embodiment, when packaging the latest block, the accounting node is set to give priority to calling the can_invoke function in the second smart contract. When it is determined that the trigger condition of the first smart contract is met, the first smart contract is not triggered immediately. Instead, an internal transaction is first generated according to the invoke function in the second smart contract and the first smart contract, and then the internal transaction is placed in the transaction pool. When the accounting node wants to package the current latest block, it can give priority to packaging the internal transaction into the latest block according to the identifier of the internal transaction in the transaction pool. At the same time, in the process of packaging the internal transaction into the latest block or after the internal transaction is packaged into the latest block, the accounting node executes the internal transaction, triggering the first smart contract to generate internal transaction data, thereby ensuring the timeliness of the triggering of the first smart contract.
[0171] In an exemplary embodiment, the second smart contract may include an action function. Triggering the execution of the first smart contract through the second smart contract to generate the internal transaction data may include: generating at least one internal transaction based on the action function and the first smart contract; packaging each internal transaction into the first block; and executing each internal transaction in the first block to trigger the corresponding first smart contract and generate the internal transaction data.
[0172] In an exemplary embodiment, the method may further include: selecting target transaction data to be packaged from the transaction data to be packaged in the transaction pool; and packaging the target transaction data to be packaged into a second block. Figure 10 Description of embodiments.
[0173] Figure 10 The figure schematically shows a flowchart of a blockchain-based data processing method according to an embodiment of the present disclosure. Figure 10 The method provided in the embodiment may include the following steps.
[0174] In step S1001, the second smart contract is called.
[0175] In step S1002, the second smart contract is used to determine whether the triggering condition of the first smart contract is met.
[0176] Steps S1001 and S1002 can refer to the above Figure 7 Steps S705 and S706 in the embodiment.
[0177] In step S1003, at least one internal transaction is generated according to the action function in the second smart contract and the first smart contract.
[0178] Figure 10 In this embodiment, multiple first smart contracts may be included, such as the first smart contract "A" described above, and a first smart contract "B" for executing invoice transactions at 5:00 PM every night. The accounting node may generate multiple internal transactions, such as invoke(A) and invoke(B), based on the invoke function in the second smart contract and the multiple first smart contracts.
[0179] In step S1004, each internal transaction is packaged into the first block.
[0180] The accounting node may prioritize packaging the multiple internal transactions into the first block.
[0181] In step S1005, each internal transaction in the first block is executed, triggering the corresponding first smart contract and generating internal transaction data.
[0182] Figure 10 In this embodiment, assuming that these multiple internal transactions are sufficient to generate a first block, the accounting node no longer needs to select from the transaction pool. After packaging the first block, the accounting node can execute each internal transaction in the first block, trigger the corresponding first smart contract, such as triggering the above-mentioned first smart contracts A and B, generate internal transaction data, and record the internal transaction data in the first block.
[0183] In step S1006, the first block is broadcast to the blockchain network.
[0184] Step S1006 can refer to the above Figure 3 Step S330 in the embodiment.
[0185] In step S1007, target transaction data to be packaged is selected from the transaction data to be packaged in the transaction pool.
[0186] In step S1008, the target transaction data to be packaged is packaged to generate a second block.
[0187] In step S1009, the second block is broadcast to the blockchain network.
[0188] The accounting node broadcasts the second block to other nodes in the blockchain network. After receiving the second block, other nodes reach consensus on the second block.
[0189] Figure 10 In an embodiment, if there are multiple first smart contracts, the accounting node is set to preferentially call the can_invoke function in the second smart contract when packaging the latest block. When it is determined that the triggering condition of the first smart contract is met, the multiple first smart contracts are not triggered immediately, but multiple internal transactions are first generated according to the invoke function in the second smart contract and the multiple first smart contracts, and the multiple internal transactions are preferentially packaged into the latest first block. If the multiple internal transactions are sufficient to be packaged into a first block, the accounting node can package the target transaction data from the transaction pool instead of selecting the target transaction data from the transaction pool when packaging the second block next time.
[0190] It is understandable that Figure 10 In the embodiment, multiple internal transactions can also be placed in the transaction pool first, and then the accounting node can package them into the first block first according to the identifier of each internal transaction. In the process of packaging the first block, each internal transaction can also be executed simultaneously to trigger the corresponding first smart contract.
[0191] The following combination Figure 11 The blockchain-based data processing method provided in the embodiments of the present disclosure is illustrated by way of example.
[0192] Figure 11 In an embodiment, the blockchain may include a system-level smart contract (a second smart contract) for storing contract active triggering logic. In an exemplary embodiment, the system-level smart contract may be stored in each node of the blockchain. For example, the system-level smart contract may be set by any node in the blockchain and broadcast to other nodes in the blockchain. The system-level smart contract is set as a code language or other executable form that the accounting node needs to actively execute before generating a new block. The system-level smart contract may include one or more contract active triggering logics, each of which may be uploaded by any node in the blockchain (hereinafter referred to as the user node). For example, each node in the blockchain may generate a contract active triggering logic that needs to be actively executed according to the settings, and upload it to the system-level smart contract.
[0193] Figure 11 In this example, user 1 initiates a transaction with a system-level smart contract and registers the contract's active triggering logic. This active triggering logic includes at least one first smart contract's active triggering logic, which includes the can_invoke function (trigger condition function) and the invoke function (action function). After this step, user 1 no longer needs to perform any further operations.
[0194] A trigger condition function may include a conditional statement for the trigger condition and the trigger condition result corresponding to the trigger condition. The system-level smart contract may also include execution flows for different conditional results. For example, if the trigger condition is met, an action function may be triggered; if the trigger condition is not met, the contract actively triggers the logic to terminate the process. The action function may include a call statement for the first smart contract. For example, when user 1 generates the active trigger logic for a contract that they wish to upload to the blockchain, they may determine the internal transactions they wish the trigger condition function to trigger based on their needs. They then include the call statement for the first smart contract involved in the internal transaction in the action function. This allows the action function to be triggered to invoke the first smart contract within the action function when the trigger condition is met. Invoking the action function enables the execution of the internal transaction corresponding to the first smart contract.
[0195] Before constructing the latest block (e.g., the first block mentioned above), the ledger node can call the trigger condition function can_invoke based on the current state of the blockchain. If the trigger condition is not met, the can_invoke function returns false. If the trigger condition is met, the can_invoke function returns true and the parameters required for subsequent calls to the invoke function.
[0196] For example, the trigger condition function may include a numerical determination of the current state of the blockchain, or a numerical determination statement for a calculation result related to the current state of the blockchain. When the numerical determination result is yes, the current state of the blockchain may be considered to satisfy the trigger condition of the trigger condition function. For example, when the current state of the blockchain is the block height of the blockchain, the trigger condition function may include a numerical determination statement for the block height of the blockchain. Assuming that the numerical determination statement for the block height of the blockchain is: Is the block height equal to 1000? If the block height of the blockchain is equal to 1000, then the numerical determination result of the numerical determination statement is confirmed to be yes, and the current state of the blockchain satisfies the trigger condition.
[0197] After the trigger condition is met, the action function triggers a matching first smart contract, which can be a smart contract pre-written in the action function. By triggering the first smart contract, the state of the first smart contract can be obtained, and the current state of the blockchain can be updated based on the state of the first smart contract.
[0198] The first smart contract is stored on the blockchain and includes: (1) an executable code; (2) the state of the contract itself. The process of the first smart contract being triggered by an internal transaction can be abstracted into the following formula: S' = F(S,TX), where TX is the incoming internal transaction, S is the state before the execution of the first smart contract, F is the logic of the first smart contract execution (determined by the executable code of the first smart contract), and S' is the new state after the execution of the first smart contract. The deployment and execution of the first smart contract and the second smart contract have both been through the consensus of the blockchain nodes, and malicious nodes cannot affect the consensus results of the entire network. Therefore, smart contracts have the characteristics of decentralization and trustworthiness.
[0199] In the disclosed embodiments, action function inputs can be set based on actual circumstances when User 1 generates the contract's active trigger logic. User 1 can set action function inputs based on the internal transaction method. For example, the action function inputs can include one or more parameters, and each action function can be a fixed value or a calculation formula that includes the current state of the blockchain. This disclosure does not impose any specific limitations on this.
[0200] In the embodiment of the present disclosure, the action function input parameter can be used as the input parameter of the action function to execute the action function, thereby triggering and executing the first smart contract that matches the action function.
[0201] Figure 11In this embodiment, the accounting node can select target transaction data from the transaction pool and package it into a new block. The accounting node can execute the transactions in the new block and update the blockchain state. The accounting node can also broadcast the new block to other nodes, and upload it to the blockchain after consensus is reached.
[0202] Figure 11 In this example, assume that User 2 maintains a contract trigger service. The contract trigger service continuously synchronizes relevant information, such as the blockchain state. If the current blockchain state meets the contract trigger conditions (the contract trigger conditions here are assumed to be non-timely, meaning that the corresponding smart contract does not need to be prioritized for execution, and therefore the corresponding transaction data to be packaged does not need to be prioritized), the contract trigger service constructs the transaction data to be packaged and broadcasts it to the transaction pool.
[0203] In some embodiments, the current state of the blockchain may include a block height, and the trigger condition in the trigger condition function may include: the block height is a multiple of a preset height value, and the first smart contract may include a lottery transaction execution function.
[0204] For example, user 1 may have the following requirement: a lottery draw is held every 1000 blocks. In this case, the trigger condition in the trigger condition function may be: the block height is a multiple of 1000. The trigger condition function can be expressed as follows:
[0205]
[0206] Among them, when the block height is a multiple of the preset height value, the trigger condition function can return true, and it is considered that the current state of the blockchain meets the trigger condition in the trigger condition function.
[0207] The lottery transaction execution function can be used to execute lottery transactions. For example, after the winner is determined from the participating users, a certain amount of electronic resources in User 1's account is transferred to the winning user's account to execute the lottery transaction, thereby completing the execution of the internal transaction (i.e., the game lottery transaction) and updating the blockchain status based on the executed status of the first smart contract corresponding to the internal transaction (assuming it is the lottery smart contract in this case).
[0208] Among them, the action function can be expressed as follows.
[0209]
[0210] In other embodiments, the trigger condition in the trigger condition function may include: the current time is the same as the preset condition trigger time, and the first smart contract may include an electronic bill circulation transaction execution function.
[0211] In embodiments of the present disclosure, the preset conditional trigger time may be, for example, a fixed time point within each preset time period. The preset time period may be, for example, but not limited to, one hour, one day, one week, one month, or one year. For example, the preset conditional trigger time may be 5:00 PM daily, but this is merely an example and the present disclosure is not limited thereto. If user 1 is an enterprise, user 1 may have the following requirement: execute an electronic bill circulation transaction at 5:00 PM daily. In this case, the trigger condition in the trigger condition function may be: the current time is 5:00 PM.
[0212] In the disclosed embodiments, the electronic bill transfer transaction execution function can be used to execute electronic bill transfer transactions. For example, the action function can be used to transfer the electronic bills of the user node within the current preset time period to the tax bureau node to execute the electronic bill transfer transaction (i.e., internal transaction) to complete the tax filing process on time. The blockchain status is then updated based on the status of the first smart contract corresponding to the internal transaction after execution.
[0213] In yet other embodiments, the current state of the blockchain may include electronic invoice issuance records, and the trigger condition in the trigger condition function may include: the number of electronic invoice issuance records within a preset time range is greater than a preset issuance quantity threshold. The first smart contract may include an electronic invoice marking execution function. If the number of electronic invoice issuance records within the preset time range is greater than the preset issuance quantity threshold, the current state of the blockchain is determined to satisfy the trigger condition in the trigger condition function.
[0214] In the embodiment of the present disclosure, the preset time range may be, for example, from midnight to 5 a.m. daily, and the preset issuance quantity threshold may be, for example, 5. However, the preset time range and preset issuance quantity threshold are merely examples, and the present disclosure is not limited thereto. For example, if user 1 receives an electronic invoice issuance operation exceeding the preset issuance quantity threshold (e.g., 5) within the preset time range (e.g., from midnight to 5 a.m.), the generated electronic invoice may be considered suspicious, and the current state of the blockchain may be confirmed to satisfy the trigger condition in the trigger condition function.
[0215] In the disclosed embodiments, the electronic invoice marking execution function can be used to perform a marking operation on a specified electronic invoice. For example, the electronic invoice can be marked during the issuance transaction of the electronic invoice to complete the execution of the internal transaction and update the blockchain status based on the status of the first smart contract corresponding to the internal transaction.
[0216] The blockchain-based data processing method of the present embodiment, on the one hand, introduces a system-level smart contract within the blockchain that stores the contract's active triggering logic (including trigger condition functions and action functions). Each time a block is constructed, the accounting node first calls the trigger condition function based on the latest state of the blockchain to determine whether the trigger condition is met. If so, it then calls the action function to trigger the first smart contract. This provides an active triggering mode for smart contracts, supporting automated triggering of the first smart contract. Once the trigger condition is met, the first smart contract can be automatically triggered by a second smart contract, eliminating the need for external transactions initiated by external accounts. This active triggering mode offers optimal timeliness, triggering the first smart contract immediately upon meeting the trigger condition, ensuring the timely triggering of the first smart contract. Furthermore, user 1 only needs to register the contract's active triggering logic within the system-level smart contract, eliminating the need to maintain a contract triggering service like user 2 does. Furthermore, the distributed and decentralized nature of the blockchain prevents downtime. Hackers are extremely difficult to attack the entire blockchain system. Therefore, the active triggering mode is highly reliable.
[0217] The following describes an embodiment of a device disclosed herein that can be used to execute the blockchain-based data processing method described above. For details not disclosed in the embodiment of the device disclosed herein, please refer to the embodiment of the blockchain-based data processing method described above.
[0218] Figure 12 A block diagram schematically illustrates a blockchain-based data processing device according to an embodiment of the present disclosure. A blockchain network may include a ledger node, a first smart contract may be deployed in the blockchain network, and the method may be executed by the ledger node. The blockchain network may include a transaction pool, which may include transaction data to be packaged.
[0219] Reference Figure 12 As shown, the blockchain-based data processing device 1200 according to an embodiment of the present disclosure may include: an internal transaction data acquisition unit 1210, a first block generation unit 1220 and a second block broadcasting unit 1230.
[0220] In the disclosed embodiment, the internal transaction data acquisition unit 1210 can be used to acquire internal transaction data, where the internal transaction data is obtained by triggering the first smart contract, and the internal transaction data has a higher packaging priority than at least a portion of the transaction data to be packaged. The first block generation unit 1220 can be used to package the internal transaction data and generate a first block. The second block broadcast unit 1230 can be used to broadcast the first block to the blockchain network.
[0221] The blockchain-based data processing device provided by the embodiments of the present disclosure prioritizes obtaining internal transaction data generated by triggering a first smart contract deployed in the blockchain network when packaging the current first block, compared to transaction data to be packaged with a lower packaging priority in the transaction pool of the blockchain network, and packages the internal transaction data into the first block. This enables internal transaction data with a high packaging priority to be packaged into the first block first, and the internal transaction data is obtained by triggering the first smart contract deployed in the blockchain network, thereby ensuring that the triggering of the first smart contract meets the timeliness.
[0222] In an exemplary embodiment, a second smart contract may also be deployed in the blockchain network. The internal transaction data acquisition unit 1210 may include: a second smart contract invoking unit configured to invoke the second smart contract; a trigger condition determination unit configured to utilize the second smart contract to determine whether the trigger condition of the first smart contract is satisfied; and a first smart contract triggering unit configured to trigger the execution of the first smart contract through the second smart contract to generate the internal transaction data.
[0223] In an exemplary embodiment, a second smart contract may be deployed in the blockchain network, and the blockchain network may also include non-accounting nodes. The internal transaction data acquisition unit 1210 may include an internal transaction data receiving unit configured to receive the internal transaction data from the non-accounting nodes. The non-accounting nodes may be configured to invoke the second smart contract, determine through the second smart contract whether the triggering conditions of the first smart contract are met, trigger the execution of the first smart contract using the second smart contract, and generate and broadcast the internal transaction data.
[0224] In an exemplary embodiment, the second smart contract may include an action function. The first smart contract triggering unit may include an action function triggering unit configured to invoke the action function to trigger the first smart contract and generate the internal transaction data. The blockchain-based data processing device 1200 may further include a first target transaction data to be packaged selection unit configured to select target transaction data to be packaged from the transaction data to be packaged in the transaction pool after invoking the action function to trigger the first smart contract and generating the internal transaction data; and a first target transaction data to be packaged packaging unit configured to package the target transaction data to be packaged into the first block.
[0225] In an exemplary embodiment, the second smart contract may include an action function. The first smart contract triggering unit may include: a first internal transaction generating unit configured to generate an internal transaction based on the action function and the first smart contract; an internal transaction packaging unit configured to package the internal transaction into the first block; a second target transaction data to be packaged selecting unit configured to select target transaction data to be packaged from the transaction data to be packaged in the transaction pool; a second target transaction data to be packaged packaging unit configured to package the target transaction data to be packaged into the first block; and a first internal transaction executing unit configured to execute the internal transaction in the first block to trigger the first smart contract to generate the internal transaction data.
[0226] In an exemplary embodiment, the second smart contract may include an action function. The first smart contract triggering unit may include: a second internal transaction generating unit configured to generate an internal transaction based on the action function and the first smart contract; and a packaging contract triggering unit configured to trigger the first smart contract and generate the internal transaction data during the packaging of the internal transaction into the first block.
[0227] In an exemplary embodiment, the second smart contract may include an action function. The first smart contract triggering unit may include: a third internal transaction generating unit configured to generate an internal transaction based on the action function and the first smart contract; an internal transaction placing unit configured to place the internal transaction into the transaction pool; a to-be-packaged data selecting unit configured to select target to-be-packaged transaction data from the transaction pool among the internal transaction and the to-be-packaged transaction data; a to-be-packaged data packaging unit configured to package the internal transaction and the target to-be-packaged transaction data into the first block; and a second internal transaction executing unit configured to execute the internal transaction in the first block, trigger the first smart contract, and generate the internal transaction data.
[0228] In an exemplary embodiment, the second smart contract may include an action function. The first smart contract triggering unit may include: a fourth internal transaction generating unit configured to generate at least one internal transaction based on the action function and the first smart contract; multiple internal transaction packaging units configured to package each internal transaction into the first block; and a first block execution unit configured to execute each internal transaction in the first block, triggering the corresponding first smart contract and generating the internal transaction data.
[0229] In an exemplary embodiment, the blockchain-based data processing device 1200 may also include: a third target transaction data packaging unit for selecting target transaction data to be packaged from the transaction data to be packaged in the transaction pool; a second block packaging unit for packaging the target transaction data to be packaged into a second block; and a second block broadcasting unit for broadcasting the second block to the blockchain network.
[0230] Figure 13 Schematic diagram of the structure of an electronic device suitable for implementing the embodiment of the present disclosure is shown. Figure 13 The electronic device 1300 shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0231] like Figure 13 As shown, electronic device 1300 includes a central processing unit (CPU) 1301, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 1302 or programs loaded from a storage unit 1308 into a random access memory (RAM) 1303. Various programs and data required for system operation are also stored in RAM 1303. CPU 1301, ROM 1302, and RAM 1303 are connected to each other via a bus 1304. An input / output (I / O) interface 1305 is also connected to bus 1304.
[0232] The following components are connected to the I / O interface 1305: an input section 1306 including a keyboard, a mouse, and the like; an output section 1307 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and speakers; a storage section 1308 including a hard disk; and a communication section 1309 including a network interface card such as a LAN card or a modem. The communication section 1309 performs communication processing via a network such as the Internet. A drive 1310 is also connected to the I / O interface 1305 as needed. Removable media 1311, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 1310 as needed, so that computer programs read therefrom can be installed in the storage section 1308 as needed.
[0233] In particular, according to an embodiment of the present disclosure, the process described below with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 1309, and / or installed from a removable medium 1311. When the computer program is executed by the central processing unit (CPU) 1301, various functions defined in the system of the present application are executed.
[0234] It should be noted that the computer-readable medium described in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection having at least one conductor, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wireline, optical fiber cable, RF, or any suitable combination thereof.
[0235] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the above-mentioned module, program segment, or a part of code contains at least one executable instruction for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0236] The modules and / or units and / or sub-units described in the embodiments of the present disclosure may be implemented in software or hardware, and the modules and / or units and / or sub-units may also be provided in a processor. The names of these modules and / or units and / or sub-units do not, in certain circumstances, limit the modules and / or units and / or sub-units themselves.
[0237] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the method described in the following embodiment. For example, the electronic device may implement the following Figure 3 or Figure 4 or Figure 5 or Figure 7 or Figure 8 or Figure 9 or Figure 10 or Figure 11 The steps shown.
[0238] It should be noted that although several modules or units or subunits of the device for action execution are mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units or subunits described above can be concretized in one module or unit or subunit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units or subunits to be concretized.
[0239] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
Claims
1. A data processing method based on blockchain, wherein the blockchain network includes accounting nodes, characterized in that: A first smart contract and a second smart contract are deployed in the blockchain network, wherein the second smart contract includes a trigger condition function and an action function, and the trigger condition of the first smart contract is set in the trigger condition function; The method is executed by the accounting node, the blockchain network includes a transaction pool, and the transaction pool includes transaction data to be packaged; wherein the method includes: Obtaining internal transaction data, comprising: calling the second smart contract; determining, using the trigger condition function in the second smart contract, whether a trigger condition of the first smart contract is satisfied; generating an internal transaction according to the action function and the first smart contract; packaging the internal transaction into the first block; selecting target transaction data to be packaged from the transaction data to be packaged in the transaction pool; packaging the target transaction data to be packaged into the first block; executing the internal transaction in the first block to trigger the first smart contract to generate the internal transaction data; wherein the packaging priority of the internal transaction data is higher than that of at least some of the transaction data to be packaged; Packaging the internal transaction data to generate a first block; Broadcast the first block to the blockchain network.
2. The method according to claim 1, wherein The blockchain network also includes non-bookkeeping nodes; wherein obtaining internal transaction data includes: Receiving the internal transaction data from the non-bookkeeping node; The non-bookkeeping node is used to call the second smart contract, determine through the second smart contract whether the triggering condition of the first smart contract is met, use the second smart contract to trigger the execution of the first smart contract, and generate and broadcast the internal transaction data.
3. A data processing method based on blockchain, wherein the blockchain network includes accounting nodes, characterized in that: A first smart contract and a second smart contract are deployed in the blockchain network, wherein the second smart contract includes a trigger condition function and an action function, and the trigger condition of the first smart contract is set in the trigger condition function; The method is executed by the accounting node, the blockchain network includes a transaction pool, and the transaction pool includes transaction data to be packaged; wherein the method includes: Obtaining internal transaction data, comprising: calling the second smart contract; determining, using the trigger condition function in the second smart contract, that a trigger condition of the first smart contract is satisfied; generating an internal transaction based on the action function and the first smart contract; and triggering the first smart contract to generate the internal transaction data during packaging of the internal transaction into the first block; wherein the packaging priority of the internal transaction data is higher than that of at least a portion of the transaction data to be packaged; Packaging the internal transaction data to generate a first block; Broadcast the first block to the blockchain network.
4. The method according to claim 3, wherein The blockchain network also includes non-bookkeeping nodes; wherein obtaining internal transaction data includes: Receiving the internal transaction data from the non-bookkeeping node; The non-bookkeeping node is used to call the second smart contract, determine through the second smart contract whether the triggering condition of the first smart contract is met, use the second smart contract to trigger the execution of the first smart contract, and generate and broadcast the internal transaction data.
5. A data processing method based on blockchain, wherein the blockchain network includes accounting nodes, characterized in that: A first smart contract and a second smart contract are deployed in the blockchain network, wherein the second smart contract includes a trigger condition function and an action function, and the trigger condition of the first smart contract is set in the trigger condition function; The method is executed by the accounting node, the blockchain network includes a transaction pool, and the transaction pool includes transaction data to be packaged; wherein the method includes: Obtaining internal transaction data, comprising: calling the second smart contract; using the trigger condition function in the second smart contract to determine whether a trigger condition of the first smart contract is satisfied; generating an internal transaction according to the action function and the first smart contract; placing the internal transaction into the transaction pool; selecting the internal transaction and target transaction data to be packaged from the transaction pool; packaging the internal transaction and the target transaction data to be packaged into a first block; executing the internal transaction in the first block, triggering the first smart contract, and generating the internal transaction data; wherein the packaging priority of the internal transaction data is higher than that of at least part of the transaction data to be packaged; Packaging the internal transaction data to generate a first block; Broadcast the first block to the blockchain network.
6. The method according to claim 5, wherein The blockchain network also includes non-bookkeeping nodes; wherein obtaining internal transaction data includes: Receiving the internal transaction data from the non-bookkeeping node; The non-bookkeeping node is used to call the second smart contract, determine through the second smart contract whether the triggering condition of the first smart contract is met, use the second smart contract to trigger the execution of the first smart contract, and generate and broadcast the internal transaction data.
7. A data processing method based on blockchain, wherein the blockchain network includes accounting nodes, characterized in that: A first smart contract and a second smart contract are deployed in the blockchain network, wherein the second smart contract includes a trigger condition function and an action function, and the trigger condition of the first smart contract is set in the trigger condition function; The method is executed by the accounting node, the blockchain network includes a transaction pool, and the transaction pool includes transaction data to be packaged; wherein the method includes: Obtaining internal transaction data, comprising: invoking the second smart contract; determining, using the trigger condition function in the second smart contract, whether a trigger condition of the first smart contract is satisfied; generating at least one internal transaction based on the action function and the first smart contract; packaging each internal transaction into the first block; executing each internal transaction in the first block, triggering the corresponding first smart contract, and generating the internal transaction data; wherein the packaging priority of the internal transaction data is higher than that of at least a portion of the transaction data to be packaged; Packaging the internal transaction data to generate a first block; Broadcast the first block to the blockchain network.
8. The method according to claim 7, wherein The blockchain network also includes non-bookkeeping nodes; wherein obtaining internal transaction data includes: Receiving the internal transaction data from the non-bookkeeping node; The non-bookkeeping node is used to call the second smart contract, determine through the second smart contract whether the triggering condition of the first smart contract is met, use the second smart contract to trigger the execution of the first smart contract, and generate and broadcast the internal transaction data.
9. The method according to claim 7, wherein The method further comprises: Selecting target transaction data to be packaged from the transaction data to be packaged in the transaction pool; Packing the target transaction data to be packaged into a second block; Broadcast the second block to the blockchain network.
10. A data processing device based on blockchain, wherein the blockchain network includes accounting nodes, characterized in that: The first smart contract and the second smart contract are deployed in the blockchain network, wherein the second smart contract includes an action function; the device is set in the accounting node, the blockchain network includes a transaction pool, and the transaction pool includes transaction data to be packaged; wherein the device includes: An internal transaction data acquisition unit, configured to acquire internal transaction data, comprising: invoking the second smart contract; determining, using the second smart contract, whether a trigger condition of the first smart contract is satisfied; generating an internal transaction according to the action function and the first smart contract; packaging the internal transaction into the first block; selecting target transaction data to be packaged from the transaction data to be packaged in the transaction pool; packaging the target transaction data to be packaged into the first block; executing the internal transaction in the first block to trigger the first smart contract to generate the internal transaction data; wherein the packaging priority of the internal transaction data is higher than that of at least some of the transaction data to be packaged; A first block generation unit, configured to package the internal transaction data and generate a first block; A first block broadcasting unit is configured to broadcast the first block to the blockchain network.
11. A data processing device based on blockchain, wherein the blockchain network includes accounting nodes, characterized in that: A first smart contract and a second smart contract are deployed in the blockchain network, wherein the second smart contract includes a trigger condition function and an action function, and the trigger condition of the first smart contract is set in the trigger condition function; The device is provided at the accounting node, the blockchain network includes a transaction pool, and the transaction pool includes transaction data to be packaged; wherein the device includes: an internal transaction data acquisition unit, configured to acquire internal transaction data, comprising: invoking the second smart contract; determining, using the trigger condition function in the second smart contract, that a trigger condition of the first smart contract is satisfied; generating an internal transaction based on the action function and the first smart contract; and triggering the first smart contract to generate the internal transaction data during packaging of the internal transaction into the first block; wherein the internal transaction data has a higher packaging priority than at least a portion of the transaction data to be packaged; A first block generation unit, configured to package the internal transaction data and generate a first block; A first block broadcasting unit is configured to broadcast the first block to the blockchain network.
12. A data processing device based on blockchain, wherein the blockchain network includes accounting nodes, characterized in that: A first smart contract and a second smart contract are deployed in the blockchain network, wherein the second smart contract includes a trigger condition function and an action function, and the trigger condition of the first smart contract is set in the trigger condition function; The device is provided at the accounting node, the blockchain network includes a transaction pool, and the transaction pool includes transaction data to be packaged; wherein the device includes: An internal transaction data acquisition unit, configured to acquire internal transaction data, comprising: invoking the second smart contract; determining, using the trigger condition function in the second smart contract, whether the trigger condition of the first smart contract is satisfied; generating an internal transaction based on the action function and the first smart contract; placing the internal transaction into the transaction pool; selecting, from the transaction pool, the internal transaction and target transaction data to be packaged from the transaction data to be packaged; packaging the internal transaction and the target transaction data to be packaged into a first block; executing the internal transaction in the first block, triggering the first smart contract, and generating the internal transaction data; wherein the packaging priority of the internal transaction data is higher than that of at least some of the transaction data to be packaged; A first block generation unit, configured to package the internal transaction data and generate a first block; A first block broadcasting unit is configured to broadcast the first block to the blockchain network.
13. A data processing device based on blockchain, wherein the blockchain network includes accounting nodes, characterized in that: A first smart contract and a second smart contract are deployed in the blockchain network, wherein the second smart contract includes a trigger condition function and an action function, and the trigger condition of the first smart contract is set in the trigger condition function; The device is provided at the accounting node, the blockchain network includes a transaction pool, and the transaction pool includes transaction data to be packaged; wherein the device includes: An internal transaction data acquisition unit, configured to acquire internal transaction data, comprising: invoking the second smart contract; determining, using the trigger condition function in the second smart contract, whether a trigger condition of the first smart contract is satisfied; generating at least one internal transaction based on the action function and the first smart contract; packaging each internal transaction into the first block; executing each internal transaction in the first block, triggering the corresponding first smart contract, and generating the internal transaction data; wherein the packaging priority of the internal transaction data is higher than that of at least a portion of the transaction data to be packaged; A first block generation unit, configured to package the internal transaction data and generate a first block; A first block broadcasting unit is configured to broadcast the first block to the blockchain network.
14. An electronic device, characterized in that: include: at least one processor; a storage device for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1 to 9.
15. A computer-readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
16. A computer program product, comprising computer instructions, wherein a processor executes the computer instructions to implement the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Timing system contract triggering and calling method based on blockchain technology
CN107886329A
Method and device for monitoring transaction content in block chain
CN110009494A
Data processing method and device, node equipment and storage medium
CN110717762A
User level-based blockchain transaction block output method and system
CN111461880A