Block chain transaction simulation method and device, electronic equipment and readable medium
By performing blockchain fork operations and simulated transactions in simulated blockchain transactions, the problem of the difference between simulated blockchain and actual blockchain data is solved, and the degree of simulation and accuracy of simulated transactions is improved.
Patent Information
- Application Number
- CN202310611300.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-26
- Publication Date
- 2024-11-26
AI Technical Summary
There is a data difference between simulated blockchain transactions and actual blockchain transactions, which affects the degree of simulated transactions.
By obtaining a simulated transaction request, a blockchain forking operation is performed in response to the request to generate a forked block, a simulated block environment is established, a simulated transaction is carried out in this environment, and a simulation result is generated based on data changes to ensure that the simulated environment and the actual environment are consistency.
The data difference between simulated blockchain and actual blockchain is eliminated, and the degree of simulated transactions is improved, and the accuracy and reliability of simulated transactions are improved.
Smart Images

Figure CN119027232A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, electronic device and readable medium for simulating blockchain transactions. Background Art
[0002] A simulated transaction is a transaction that does not expect the modification of blockchain data to leave traces in the blockchain. Blockchain can simulate transactions when it is necessary to confirm the impact of a transaction on the blockchain before the transaction is officially uploaded to the blockchain or when the logic of a smart contract needs to be debugged.
[0003] Simulated transactions are usually conducted in a simulated chain. A simulated blockchain is a blockchain built based on the code of an actual blockchain. Users conduct simulated transactions by conducting transactions in the simulated chain.
[0004] However, in such schemes, the transaction environment and on-chain data of the simulated blockchain are usually set up independently, which are different from the transaction environment and on-chain data in the actual blockchain, making the influencing factors of simulated transactions different from those of actual blockchain transactions, affecting the degree of realism of simulated transactions. Summary of the invention
[0005] Based on the above technical problems, the present application provides a simulation method, device, electronic device and readable medium for blockchain transactions to eliminate the data differences between the simulated blockchain and the actual blockchain and improve the realism of the simulated transaction.
[0006] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.
[0007] According to one aspect of an embodiment of the present application, a method for simulating a blockchain transaction is provided, comprising:
[0008] Get simulated transaction request;
[0009] In response to the simulated transaction request, performing a blockchain fork operation according to the latest block of the blockchain to generate a forked block, and establishing a simulated block environment of the blockchain according to the forked block;
[0010] Performing simulated transactions in the simulated block environment according to the simulated transaction request;
[0011] According to the data changes in the simulated block environment, a simulation result of the blockchain transaction is generated.
[0012] According to one aspect of an embodiment of the present application, a simulation device for blockchain transactions is provided, including:
[0013] The acquisition module is used to obtain simulated transaction requests;
[0014] A forking module, configured to respond to the simulated transaction request, perform a blockchain forking operation according to the latest block of the blockchain to generate a forked block, and establish a simulated block environment of the blockchain according to the forked block;
[0015] A simulation module, used for performing a simulated transaction according to the simulated transaction request in the simulated block environment;
[0016] The generation module is used to generate a simulation result of the blockchain transaction according to the data changes in the simulated block environment.
[0017] In some embodiments of the present application, based on the above technical solution, the simulation module is further configured to: determine the transaction type of the simulated transaction request according to the transaction information in the simulated transaction request; if the transaction type of the simulated transaction request is an intra-chain transaction, then according to the account addresses of the two parties to the transaction in the blockchain and the transaction amount of virtual resources in the simulated transaction request, call the simulated transaction interface corresponding to the intra-chain transaction to perform a simulated transaction and update the blockchain data of the forked block in the simulated block environment; if the transaction type of the simulated transaction request is a cross-chain transaction, then according to the smart contract address, smart contract call parameters and account address in the simulated transaction request, call the simulated transaction interface corresponding to the cross-chain transaction to perform a simulated transaction and update the blockchain data of the forked block in the simulated block environment.
[0018] In some embodiments of the present application, based on the above technical solution, the generation module is also configured to: obtain, through the simulation transaction interface, the simulation transaction result returned by the simulation transaction interface; obtain from the simulation transaction result the transaction volume of virtual resources in the simulation transaction, the smart contract information called by the simulation transaction, and the log data output by the called smart contract, to obtain the simulation result of the blockchain transaction.
[0019] In some embodiments of the present application, based on the above technical solution, the simulation module is also configured to: check the virtual resource type in the simulated transaction request and the account addresses of the two parties to the transaction; if the simulated transaction request contains multiple virtual resource types or one of the account addresses of the two parties to the transaction is a smart contract address, then determine that the transaction type of the simulated transaction request is a cross-chain transaction; if the simulated transaction request contains a single virtual resource type and the account addresses of the two parties to the transaction are both account addresses in the blockchain, then determine that the transaction type of the simulated transaction request is an intra-chain transaction.
[0020] In some embodiments of the present application, the simulated transaction request includes multiple groups of transaction information. Based on the above technical solution, the simulation module is also configured to: input the account addresses of the two parties to the transaction in the blockchain and the transaction amount of virtual resources in each group of transaction information into the simulated transaction interface corresponding to the intra-chain transaction, so as to return the simulated transaction result of the simulated transaction request through the simulated transaction interface, wherein the simulated transaction result includes the transaction result data of each group of transaction information conducted in the simulated transaction environment.
[0021] In some embodiments of the present application, the simulated transaction request includes multiple sets of transaction information. Based on the above technical solution, the simulation module is further configured to: sequentially call the simulated transaction interface corresponding to the intra-chain transaction according to the account addresses of the transaction parties in the blockchain and the transaction amount of virtual resources in the multiple sets of transaction information, so as to return the simulated transaction result corresponding to each set of transaction information through the simulated transaction interface;
[0022] In the process of calling the simulated transaction interface corresponding to the intra-chain transaction according to each set of transaction information, for each set of transaction information, after obtaining the simulated transaction result corresponding to the previous set of transaction information through the simulated transaction interface, the simulated transaction interface corresponding to the intra-chain transaction is called according to the current transaction information.
[0023] In some embodiments of the present application, based on the above technical solution, the simulation device for blockchain transactions further includes:
[0024] A receiving module, configured to receive a result confirmation message for the simulation result;
[0025] A packaging module, configured to package the simulated transaction information corresponding to the simulation result into a blockchain transaction in response to the result confirmation message;
[0026] A signing module, configured to sign the blockchain transaction using a blockchain key;
[0027] The on-chain module is configured to chain the signed blockchain transaction in the blockchain.
[0028] In some embodiments of the present application, based on the above technical solution, the packaging module is also configured to: in response to the result confirmation message, determine the simulated transaction information of the simulated transaction according to the transaction operations in the simulated transaction and the transaction data of the historical transactions corresponding to the transaction operations; and package the simulated transaction information into a blockchain transaction according to the information structure of the blockchain transaction in the blockchain.
[0029] In some embodiments of the present application, based on the above technical solution, the simulation device for blockchain transactions further includes:
[0030] A transaction acquisition module, configured to acquire, when a new block is generated in the blockchain, an on-chain transaction in the new block, wherein the on-chain transaction includes signature information of a transaction party account;
[0031] A signature verification module, configured to perform signature verification on the signature information in the on-chain transaction according to the key information of the transaction party account in the simulated transaction environment;
[0032] The transaction execution module is configured to execute the on-chain transaction in the new block in the simulated transaction environment if the signature verification is passed.
[0033] In some embodiments of the present application, based on the above technical solution, the transaction execution module is also configured to: parse the on-chain transactions in the new block to obtain the transaction sequence value of the on-chain transactions; retrieve the transaction sequence value of the on-chain transactions in the simulated transactions in the simulated transaction environment; if there is a historical simulated transaction with a transaction sequence value that is the same as the transaction sequence value of the on-chain transaction, then based on the historical simulated transactions, restore the data changes caused by the historical simulated transactions in the simulated transaction environment; and execute the on-chain transactions in the simulated transaction environment.
[0034] In some embodiments of the present application, based on the above technical solution, the simulated block environment corresponds to a blockchain account; the fork module is further configured to: obtain simulated transaction requests from other blockchain accounts; in response to the simulated transaction requests from the other blockchain accounts, perform a blockchain fork operation according to the latest block of the blockchain to obtain other forked blocks, and establish a simulated block environment corresponding to the other blockchain account according to the other forked blocks; the generation module is further configured to: if a simulated transaction request from the blockchain account is received, execute the simulated transaction request in the simulated block environment corresponding to the blockchain account; if a simulated transaction request from the other blockchain account is received, execute the simulated transaction request in the other simulated block environment corresponding to the blockchain account.
[0035] In some embodiments of the present application, based on the above technical solution, the acquisition module is also configured to: acquire and locally save the latest block data of the latest block in the blockchain; monitor the block chain operation in the blockchain; when a new block is chained in the blockchain, acquire the new block and update the latest block data saved locally according to the new block, so as to generate a simulated block environment of the blockchain.
[0036] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute a simulation method of blockchain transactions as in the above technical solution by executing the executable instructions.
[0037] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, a simulation method for blockchain transactions in the above technical solution is implemented.
[0038] According to one aspect of the embodiments of the present application, a computer program product or a computer program is provided, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the simulation method of blockchain transactions provided in the above-mentioned various optional implementations.
[0039] In the embodiment of the present application, during the process of simulating transactions, a simulated block environment of the blockchain is first generated according to the transaction logic information corresponding to the blockchain and the data of the latest block in the blockchain, and then a simulated transaction is performed in the simulated block environment, and then a simulated result of the blockchain transaction is generated according to the data changes in the simulated block environment. By performing simulated transactions in a simulated real environment, the data difference between the simulated blockchain and the actual blockchain is eliminated, and the degree of simulation of the simulated transaction is improved.
[0040] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0042] In the attached picture:
[0043] Figure 1 It is a system architecture of a simulation solution applied to blockchain transactions according to an embodiment of the present application.
[0044] Figure 2 This is a schematic diagram of a blockchain network in an embodiment of the present application.
[0045] Figure 3 This is a schematic diagram of blocks in a blockchain network in an embodiment of the present application.
[0046] Figure 4 The present invention is a flowchart of a method for simulating blockchain transactions according to an embodiment of the present application.
[0047] Figure 5 The present invention is a flowchart of a method for simulating blockchain transactions according to an embodiment of the present application.
[0048] Figure 6 The present invention is a flowchart of a method for simulating blockchain transactions according to an embodiment of the present application.
[0049] Figure 7 The present invention is a flowchart of a method for simulating blockchain transactions according to an embodiment of the present application.
[0050] Figure 8 The present invention is a flowchart of a method for simulating blockchain transactions according to an embodiment of the present application.
[0051] Fig. 9 The present invention is a flowchart of a method for simulating blockchain transactions according to an embodiment of the present application.
[0052] Fig.10 The present invention is a flowchart of a method for simulating blockchain transactions according to an embodiment of the present application.
[0053] Fig.11 The present invention is a flowchart of a method for simulating blockchain transactions according to an embodiment of the present application.
[0054] Fig.12 The present invention is a flowchart of a specific implementation of the simulation method of blockchain transactions in one embodiment of the present application.
[0055] Fig.13 The block diagram schematically shows the composition of the simulation device for blockchain transactions in an embodiment of the present application.
[0056] Fig.14 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION
[0057] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.
[0058] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, known methods, devices, realizations or operations are not shown or described in detail to avoid blurring the various aspects of the application.
[0059] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0060] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0061] It should be understood that the solution of the present application can be applied to the scenario of simulating transactions in blockchain. Specifically, in such scenarios, users can use their blockchain accounts to initiate transaction requests to the simulated trading system. The simulated trading system maintains a simulation environment for simulating the current blockchain state and transaction logic. The simulated trading system simulates the results of the transaction request in the actual blockchain in the running environment, and feeds the results back to the user. The user can judge the data changes and related operations involved in the transaction request based on the results. For example, the owner of the virtual resources can judge what changes will be caused to the virtual resources by conducting the transaction based on the data changes, such as how much virtual resources are spent, how much virtual resources are obtained, and how much virtual resources are needed. Blockchain maintenance personnel can check the operation status of each smart contract in the blockchain based on the relevant operations involved in the transaction. The solution of the present application can be run on the platform of the service provider or the user's own terminal device.
[0062] A simulated transaction is a transaction in which the modification of blockchain data is not expected to leave traces in the blockchain. The blockchain can simulate transactions in situations where it is necessary to confirm the impact of a transaction on the blockchain before the transaction is officially on the chain or when the logic of a smart contract needs to be debugged. Simulated transactions are usually conducted in a simulated chain. A simulated blockchain is a blockchain established based on the code of an actual blockchain. Users conduct simulated transactions by conducting transactions in the simulated chain. However, in such solutions, the transaction environment and on-chain data of the simulated blockchain are usually set up independently, and there are differences between the transaction environment and on-chain data in the actual blockchain, which makes the influencing factors of simulated transactions different from those of actual blockchain transactions, affecting the degree of simulation of simulated transactions.
[0063] Based on this, the technical solution of the embodiment of the present application proposes a simulation solution for blockchain transactions. Specifically, Figure 1 As shown, the system architecture 100 of the simulation scheme for blockchain transactions according to the embodiment of the present application may include a terminal device 110, a blockchain server 120 and a simulation server 130. The terminal device 110 may include a smart phone, a tablet computer, a laptop computer, an intelligent voice interaction device, a smart home appliance, a vehicle terminal, an aircraft, etc. The blockchain server 120 and the simulation server 130 may be servers that provide various services, which may be independent physical servers, or server clusters or distributed systems composed of multiple physical servers, or cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network, content distribution network) and big data and artificial intelligence platforms. There may be various types of communication media for the communication link between the terminal device 110 and the blockchain server 120 and the simulation server 130, such as a wired communication link or a wireless communication link.
[0064] According to the implementation needs, the system architecture in the embodiment of the present application can have any number of terminal devices and servers. For example, the blockchain server 120 and the simulation server 130 can be a server group composed of multiple server devices. In addition, the technical solution provided in the embodiment of the present application can be applied to the terminal device 110, and can also be applied to the blockchain server 120 and the simulation server 130, or can be implemented by the terminal device 110, the blockchain server 120 and the simulation server 130, and the present application does not make any special restrictions on this.
[0065] In one embodiment of the present application, the simulation server 130 obtains a simulated transaction request of a blockchain account from a user terminal. A simulated transaction request is a simulated transaction initiated by a blockchain account owner, which is intended to conduct a transaction based on the current state of the blockchain but the transaction is not actually recorded in the blockchain.
[0066] After receiving the simulated transaction request, the simulation server 130 generates a simulated block environment of the blockchain according to the transaction logic information corresponding to the blockchain and the data of the latest block in the blockchain in response to the simulated transaction request, and then performs a simulated transaction according to the simulated transaction request in the simulated block environment, and generates a simulation result of the blockchain transaction according to the data changes in the simulated block environment.
[0067] Specifically, the blockchain is a blockchain that provides virtual resource trading services. A simulated transaction request is a request for a simulated transaction of virtual resources owned by a blockchain account. Smart contracts for executing various services can be deployed in the blockchain, for example, a smart contract specifically for virtual resource conversion is deployed, and there is a conversion account for virtual resource conversion. If a virtual resource is converted to buy, the virtual resource is transferred from the conversion account to the user's account through a smart contract. Conversely, if a virtual resource is transferred to sell, the virtual resource is transferred from the user account to the conversion account through a smart contract. It is understandable that the transaction process of virtual resources in another blockchain will also be involved in the smart contract of the smart contract conversion.
[0068] Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks (i.e. blocks) generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain is maintained by the nodes in the blockchain network. For example, in Figure 2 The blockchain network shown may include multiple nodes 201, and the multiple nodes 201 may be the various clients forming the blockchain network. Each node 201 may receive input information during normal operation, and maintain the shared data in the blockchain network based on the received input information. In order to ensure the information intercommunication within the blockchain network, there may be an information connection between each node in the blockchain network, and information may be transmitted between nodes through the above information connection. For example, when any node in the blockchain network receives input information, other nodes in the blockchain network obtain the input information according to the consensus algorithm, and store the input information as shared data, so that the data stored on all nodes in the blockchain network are consistent.
[0069] Each node in the blockchain network has a corresponding node identifier, and each node in the blockchain network can store the node identifiers of other nodes, so that the generated blocks can be broadcast to other nodes in the blockchain network according to the node identifiers of other nodes. A node identifier list can be maintained in each node, and the node name and node identifier are stored in the node identifier list accordingly. The node identifier can be an IP (Internet Protocol, a protocol for interconnecting networks) address or any other information that can be used to identify the node.
[0070] Each node in the blockchain network stores the same blockchain. The blockchain consists of multiple blocks, see Figure 3 As shown, the blockchain consists of multiple blocks. The genesis block includes a block header and a block body. The block header stores input information feature values, version numbers, timestamps, and difficulty values, and the block body stores input information. The next block of the genesis block uses the genesis block as its parent block. The next block also includes a block header and a block body. The block header stores input information feature values of the current block, feature values of the block header of the parent block, version numbers, timestamps, and difficulty values, and so on. This ensures that the block data stored in each block in the blockchain is associated with the block data stored in the parent block, thereby ensuring the security of the input information in the block.
[0071] The simulation block data maintained in the simulation server 130 may be located at Figure 3 It is understandable that, although the transaction logic and data structure of the blockchain are simulated in the simulation server 130, the verification process of the simulated transaction is not necessarily completely consistent with the process in the blockchain. For example, permission verification may not be required in the simulation server 130 because its execution result will not directly affect the data in the blockchain.
[0072] Figure 4 A flowchart of a method for processing data of virtual resources according to an embodiment of the present application is shown. The method for processing data of virtual resources can be executed by a device having a computing and processing function, such as a server. Figure 4 As shown, the data processing method of the virtual resource at least includes steps S410 to S440, which are described in detail as follows:
[0073] Step S410, obtaining a simulated transaction request of a blockchain account.
[0074] The user must first log in to his blockchain account on the terminal device, and after logging in, he initiates a simulated transaction request to the simulation system through the client. The simulation system then receives the simulated transaction request initiated by the blockchain account from the client. The simulated transaction request is submitted by the account applying for simulated transaction to the simulated transaction system. The simulated transaction request usually contains the account addresses of the two parties involved in the simulated transaction and the transaction parameters involved in the simulated transaction. This information can be collected through the client. Please refer to Figure 5 , Figure 5 This is a schematic diagram of a simulated transaction request submission page in an embodiment of the present application. Figure 5 As shown, the page will contain the account addresses of both parties of the transaction, corresponding to the payer from and the receiver to, respectively. The parameter value is the parameter for calling the smart contract, and the data data is the transfer amount. For example, if you want to simulate user A transferring 1 unit of virtual resources to user B, fill in from and to with user address A and user address B respectively, data is empty, and value is 1 virtual resource. In the case of multiple blockchains, you can also select the blockchain to submit the simulated transaction on the page.
[0075] Step S420, in response to the simulated transaction request, performing a blockchain fork operation according to the latest block of the blockchain to generate a forked block, and establishing a simulated block environment of the blockchain according to the forked block.
[0076] After receiving the simulated transaction request, the simulation system responds to the request, performs a blockchain fork operation according to the latest block of the blockchain to generate a forked block, and establishes a simulated block environment of the blockchain according to the forked block. The simulation system will contain the transaction logic information corresponding to the blockchain and the data of the latest block in the blockchain. The transaction logic information corresponding to the blockchain is usually information such as the implementation code or transaction rules of the blockchain, and includes the smart contracts that have been deployed and effective in the blockchain. For the blockchain, these transaction logic information itself is usually public information, so the simulation system can be pre-configured with the transaction logic information of the blockchain to be simulated. It can be understood that the transaction rules in the transaction logic information are the same as the actual operation rules of the blockchain, but the rules that do not affect the direct transaction results, such as permission control or verification rules, can be different from the actual rules of the blockchain. The data of the latest block in the blockchain can be pre-stored in the simulation system, or it can be read from the blockchain when the simulated block environment needs to be generated. Based on these data, the simulation system can perform a blockchain fork operation according to the latest block of the blockchain to generate a forked block when processing the simulated transaction request. The fork operation can be obtained by executing the fork algorithm based on the blockchain data and blockchain logic that have been saved in the simulation system, or by directly reading the state of the current blockchain to perform the fork operation. However, the fork will not be merged with the blockchain, but will be isolated separately as the data basis for a simulated trading environment. Based on the obtained forked block and the transaction logic information such as the implementation code of the blockchain in the simulation system, the simulation system can establish a simulated block environment of the blockchain. The simulated block environment contains the blockchain data in the current blockchain and the implementation logic of the current blockchain, thereby ensuring that the transaction environment in the simulated block environment is the same as the actual environment in the blockchain. However, it can be understood that the new block does not need to be managed according to the data recording rules of the blockchain, but rather serves as the environment and data basis for the simulated transaction process and transaction results. For example, when performing simulated transactions in a simulated transaction environment, the encryption and authentication processes in the transaction process can be skipped to improve execution efficiency.
[0077] Step S430, performing a simulated transaction in the simulated block environment according to the simulated transaction request.
[0078] The simulation system will perform simulated transactions in the simulated block environment according to the simulated transaction request. In the simulated block environment, the simulated transaction will be directly executed, and the transaction result will be directly updated to the simulated block environment, skipping the consensus chain process of the blockchain. The execution process of the simulated transaction in the simulated block environment is the same as the execution process of the transaction in the actual blockchain. In addition, the data changes involved in the process of performing simulated transactions will also be recorded in the simulated block environment. For example, if blockchain account A transfers 2 units of virtual resources to blockchain account B in the simulated transaction request, after the simulated transaction, blockchain account A will deduct 2 units of virtual resources in the simulated block environment, while blockchain account B will increase 2 units of virtual resources. In other words, the data in the simulated block environment will be directly updated to the state after the blockchain transaction is chained after the simulated transaction.
[0079] Step S440, generating a simulation result of a blockchain transaction according to the data changes in the simulated block environment.
[0080] The simulation system will generate the simulation results of blockchain transactions according to the data changes in the simulated block environment. The simulation results usually include the results of the simulated transaction, that is, the changes in the virtual resources in the transaction. The simulation results can be collected from the simulated block environment. Specifically, for example, the data changes in the simulated block environment can be collected from the return results of the simulated transaction interface called, or the virtual resource change records in the simulated block environment can be used to determine, or directly compare the accounts and records related to the transaction before and after the transaction in the simulated block environment.
[0081] In the embodiment of the present application, during the process of simulating transactions, a simulated block environment of the blockchain is first generated according to the transaction logic information corresponding to the blockchain and the data of the latest block in the blockchain, and then a simulated transaction is performed in the simulated block environment, and then a simulated result of the blockchain transaction is generated according to the data changes in the simulated block environment. By performing simulated transactions in a simulated real environment, the data difference between the simulated blockchain and the actual blockchain is eliminated, and the degree of simulation of the simulated transaction is improved.
[0082] In some optional embodiments, there is a corresponding relationship between the simulated block environment generated in response to the simulated transaction request of the blockchain account and the blockchain account, and the simulation system will also obtain the simulated transaction request of other blockchain accounts, and in response to the simulated transaction request of other blockchain accounts, generate other simulated block environments corresponding to other blockchain accounts according to the transaction logic information corresponding to the blockchain and the data of the latest block in the blockchain. After generating the simulation result of the blockchain transaction according to the data changes in the simulated block environment, if the simulated transaction request of the blockchain account is received, the simulated transaction request is executed in the simulated block environment corresponding to the blockchain account; and if the simulated transaction request of other blockchain accounts is received, the simulated transaction request is executed in the other simulated block environment corresponding to the blockchain account. That is to say, for each blockchain account, a simulated block environment is generated separately, and the simulated block environment of each blockchain account will isolate the scope of other accounts, thereby avoiding the mutual influence caused by the simulated transactions of different blockchain accounts, which is conducive to ensuring the uniformity between the simulated block environment and the actual blockchain and improving the accuracy of the simulation results.
[0083] In some optional embodiments, before obtaining a simulated transaction request from a blockchain account, the simulation system obtains and locally saves the latest block data of the latest block in the blockchain, and further monitors the block chain operation in the blockchain. When a new block is chained in the blockchain, the new block is obtained and the latest block data saved locally is updated according to the new block to generate a simulated block environment for the blockchain. The timeliness of the latest block data in the simulation system is ensured by saving the latest block data and monitoring the blocks on the chain to update the local data, and by pre-reading the data from the blockchain and storing it locally in the simulation system, compared to reading data from the blockchain during the generation of the simulated block environment, the impact of the communication process on the generation process can be reduced, and the failure of the simulated transaction process caused by communication failure can be avoided, thereby improving the reliability of the solution.
[0084] In the embodiments of the present application, it is also proposed to Figure 4 Other embodiments that refine the technical solution of the embodiment shown in the figure are as follows Figure 6 As shown, in a simulation method of blockchain transactions in one embodiment of the present application, a method for processing virtual resources may include the following steps:
[0085] Step S610, obtaining a simulated transaction request of a blockchain account.
[0086] Optionally, the implementation details of step S610 are the same as Figure 4 The step S410 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0087] Step S620, in response to the simulated transaction request, performing a blockchain fork operation according to the latest block of the blockchain to generate a forked block, and establishing a simulated block environment of the blockchain according to the forked block.
[0088] Optionally, the implementation details of step S620 are the same as Figure 4 The step S420 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0089] Step S630: Determine the transaction type of the simulated transaction request according to the transaction information in the simulated transaction request.
[0090] In the scheme of the present application, there are generally two types of transfers of virtual assets, namely intra-chain transactions and cross-chain transactions. In intra-chain transactions, both parties to the transaction are blockchain accounts in the blockchain, that is, one blockchain account transfers virtual resources to another blockchain account. Cross-chain transactions usually convert virtual resources in the blockchain into another virtual resource for trading. Smart contracts are usually called in cross-chain transactions, so the data content involved in the two transactions is different when calling the simulated transaction interface. The simulation system determines the transaction type of the simulated transaction request based on the transaction information in the simulated transaction request. If the simulated transaction request is an intra-chain transaction, step S640 is executed, and if the simulated transaction request is a cross-chain transaction, step 650 is executed.
[0091] Step S640, according to the account addresses of the two parties to the transaction in the blockchain and the transaction amount of virtual resources in the simulated transaction request, call the simulated transaction interface corresponding to the intra-chain transaction to perform a simulated transaction and update the blockchain data of the forked block in the simulated block environment.
[0092] For intra-chain transactions, the simulation system mainly calls the corresponding simulation transaction interface of the intra-chain transaction based on the account addresses of the two parties in the blockchain and the transaction volume of virtual resources. This type of transaction is usually the transfer process of native virtual resources in the blockchain. This type of transaction can be executed without calling smart contracts. The simulation system will implement the specific logic of the simulation transaction interface to perform simulated transactions, and the transaction results of the simulated transaction will be updated to the blockchain data of the simulated block environment.
[0093] Step S650, according to the smart contract address, smart contract call parameters and account address in the simulated transaction request, call the simulated transaction interface corresponding to the cross-chain transaction to perform a simulated transaction and update the blockchain data of the forked block in the simulated block environment.
[0094] For cross-chain transactions, the simulation system mainly calls the simulation transaction interface corresponding to the cross-chain transaction based on the blockchain address of one party to the transaction, a smart contract address, and the transaction volume of virtual resources. For example, the transferor of virtual resources is the address of the blockchain account, and the recipient is the address of the smart contract. The virtual resource quantity parameter involved in the transaction is 0, and the call parameter of the smart contract records the virtual resource transaction volume spent by the transferor. The simulation system will implement the specific logic of the simulation transaction interface, and will also include related smart contracts to simulate transactions. It is understandable that in cross-chain transactions, the simulation system may not include the actual data of another blockchain, but only simulate the transaction results of successful transactions according to the transaction logic of the smart contract, and the transaction results of the simulated transaction will be updated to the blockchain data of the simulated block environment. By using different call interfaces for specific implementation of two different types of transactions, compared with the method of building a blockchain separately, it can more accurately simulate the transaction situations of different blocks and improve the simulation effect of simulated transactions.
[0095] Step S660, generating a simulation result of a blockchain transaction according to the data changes in the simulated block environment.
[0096] Optionally, the implementation details of step S660 are the same as Figure 4 The step S440 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0097] In the embodiment of the present application, during the process of simulating transactions, a simulated block environment of the blockchain is first generated according to the transaction logic information corresponding to the blockchain and the data of the latest block in the blockchain, and then a simulated transaction is performed in the simulated block environment, and then a simulated result of the blockchain transaction is generated according to the data changes in the simulated block environment. By performing simulated transactions in a simulated real environment, the data difference between the simulated blockchain and the actual blockchain is eliminated, and the degree of simulation of the simulated transaction is improved.
[0098] In some optional embodiments, in the process of generating the simulation results of blockchain transactions according to the data changes in the simulated block environment, the simulation system specifically obtains the simulation transaction results returned by the simulation transaction interface through the simulation transaction interface. The simulation transaction results will include the data changes involved in the simulation transaction interface in the process of executing the simulation transaction, such as the change in virtual resources of the relevant account, the smart contract call information, and the log information output during the transaction. The simulation system obtains the virtual resource transaction volume in the simulation transaction, the smart contract information called by the simulation transaction, and the log data output by the called smart contract from the simulation transaction results to obtain the simulation results of the blockchain transaction. In the case of cross-chain transactions, in addition to obtaining the changes in the virtual resources of the account, the called smart contract information and the log data output by the called smart contract will be further obtained, which is conducive to improving the information integrity in the simulation results.
[0099] In some optional embodiments, there is a corresponding relationship between the simulated block environment generated in response to the simulated transaction request of the blockchain account and the blockchain account, and the simulation system will also obtain the simulated transaction request of other blockchain accounts, and in response to the simulated transaction request of other blockchain accounts, generate other simulated block environments corresponding to other blockchain accounts according to the transaction logic information corresponding to the blockchain and the data of the latest block in the blockchain. After generating the simulation result of the blockchain transaction according to the data changes in the simulated block environment, if the simulated transaction request of the blockchain account is received, the simulated transaction request is executed in the simulated block environment corresponding to the blockchain account; and if the simulated transaction request of other blockchain accounts is received, the simulated transaction request is executed in the other simulated block environment corresponding to the blockchain account. That is to say, for each blockchain account, a simulated block environment is generated separately, and the simulated block environment of each blockchain account will isolate the scope of other accounts, thereby avoiding the mutual influence caused by the simulated transactions of different blockchain accounts, which is conducive to ensuring the uniformity between the simulated block environment and the actual blockchain and improving the accuracy of the simulation results.
[0100] In some optional embodiments, before obtaining a simulated transaction request from a blockchain account, the simulation system obtains and locally saves the latest block data of the latest block in the blockchain, and further monitors the block chain operation in the blockchain. When a new block is chained in the blockchain, the new block is obtained and the latest block data saved locally is updated according to the new block to generate a simulated block environment for the blockchain. The timeliness of the latest block data in the simulation system is ensured by saving the latest block data and monitoring the blocks on the chain to update the local data, and by pre-reading the data from the blockchain and storing it locally in the simulation system, compared to reading data from the blockchain during the generation of the simulated block environment, the impact of the communication process on the generation process can be reduced, and the failure of the simulated transaction process caused by communication failure can be avoided, thereby improving the reliability of the solution.
[0101] In the embodiments of the present application, it is also proposed to Figure 6 Other embodiments that refine the technical solution of the embodiment shown in the figure are as follows Figure 7 As shown, in a simulation method of blockchain transactions in one embodiment of the present application, a method for processing virtual resources may include the following steps:
[0102] Step S710, obtaining a simulated transaction request of a blockchain account.
[0103] Optionally, the implementation details of step S710 are the same as Figure 4 The step S410 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0104] Step S720, in response to the simulated transaction request, performing a blockchain fork operation according to the latest block of the blockchain to generate a forked block, and establishing a simulated block environment of the blockchain according to the forked block.
[0105] Optionally, the implementation details of step S720 are the same as Figure 4 The step S420 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0106] Step S730, checking the virtual resource type in the simulated transaction request and the account addresses of the transaction parties.
[0107] The virtual resource type is usually distinguished by the blockchain described by the virtual resource. The virtual resource types of virtual resources provided by the same blockchain are the same. Therefore, the blockchain name or blockchain identifier in the simulated transaction request can be used directly as the virtual resource type. The address of the smart contract is also an account address in the blockchain. From the account addresses of the two parties to the transaction, it can be identified whether the simulated transaction request involves calling a smart contract. Specifically, if the simulated transaction request contains multiple virtual resource types or one of the account addresses of the two parties to the transaction is a smart contract address, it means that the transaction required to be simulated in the simulated transaction request is a cross-chain transaction, and step S740 is executed. Otherwise, if the simulated transaction request contains a single virtual resource type and the account addresses of the two parties to the transaction are both account addresses in the blockchain, it means that the simulated transaction request requires the simulation of a virtual resource transaction between two accounts in a blockchain, and step S750 is indicated.
[0108] Step S740, determining that the transaction type of the simulated transaction request is a cross-chain transaction;
[0109] Step S750, determining that the transaction type of the simulated transaction request is an intra-chain transaction.
[0110] In the scheme of the present application, there are generally two types of transfers of virtual assets, namely intra-chain transactions and cross-chain transactions. In intra-chain transactions, both parties to the transaction are blockchain accounts in the blockchain, that is, one blockchain account transfers virtual resources to another blockchain account. Cross-chain transactions usually convert virtual resources in the blockchain into another virtual resource for trading. Smart contracts are usually called in cross-chain transactions, so the data content involved in the two transactions is different when calling the simulated transaction interface. The simulation system determines the transaction type of the simulated transaction request based on the transaction information in the simulated transaction request. If the simulated transaction request is an intra-chain transaction, step S760 is executed, and if the simulated transaction request is a cross-chain transaction, step 770 is executed.
[0111] Step S760, according to the account addresses of the two parties to the transaction in the blockchain and the transaction amount of virtual resources in the simulated transaction request, call the simulated transaction interface corresponding to the intra-chain transaction to perform a simulated transaction and update the blockchain data of the forked block in the simulated block environment.
[0112] Optionally, the implementation details of step S760 are the same as Figure 6 The step S740 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0113] Step S770, according to the smart contract address, smart contract call parameters and account address in the simulated transaction request, call the simulated transaction interface corresponding to the cross-chain transaction to perform a simulated transaction and update the blockchain data of the forked block in the simulated block environment.
[0114] Optionally, the implementation details of step S770 are the same as Figure 6 The step S650 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0115] Step S780, generating a simulation result of a blockchain transaction according to the data changes in the simulated block environment.
[0116] Optionally, the implementation details of step S780 are the same as Figure 4 The step S440 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0117] In the embodiment of the present application, during the process of simulating transactions, a simulated block environment of the blockchain is first generated according to the transaction logic information corresponding to the blockchain and the data of the latest block in the blockchain, and then a simulated transaction is performed in the simulated block environment, and then a simulated result of the blockchain transaction is generated according to the data changes in the simulated block environment. By performing simulated transactions in a simulated real environment, the data difference between the simulated blockchain and the actual blockchain is eliminated, and the degree of simulation of the simulated transaction is improved.
[0118] In some optional embodiments, in the process of generating the simulation results of blockchain transactions according to the data changes in the simulated block environment, the simulation system specifically obtains the simulation transaction results returned by the simulation transaction interface through the simulation transaction interface. The simulation transaction results will include the data changes involved in the simulation transaction interface in the process of executing the simulation transaction, such as the change in virtual resources of the relevant account, the smart contract call information, and the log information output during the transaction. The simulation system obtains the virtual resource transaction volume in the simulation transaction, the smart contract information called by the simulation transaction, and the log data output by the called smart contract from the simulation transaction results to obtain the simulation results of the blockchain transaction. In the case of cross-chain transactions, in addition to obtaining the changes in the virtual resources of the account, the called smart contract information and the log data output by the called smart contract will be further obtained, which is conducive to improving the information integrity in the simulation results.
[0119] In some optional embodiments, there is a corresponding relationship between the simulated block environment generated in response to the simulated transaction request of the blockchain account and the blockchain account, and the simulation system will also obtain the simulated transaction request of other blockchain accounts, and in response to the simulated transaction request of other blockchain accounts, generate other simulated block environments corresponding to other blockchain accounts according to the transaction logic information corresponding to the blockchain and the data of the latest block in the blockchain. After generating the simulation result of the blockchain transaction according to the data changes in the simulated block environment, if the simulated transaction request of the blockchain account is received, the simulated transaction request is executed in the simulated block environment corresponding to the blockchain account; and if the simulated transaction request of other blockchain accounts is received, the simulated transaction request is executed in the other simulated block environment corresponding to the blockchain account. That is to say, for each blockchain account, a simulated block environment is generated separately, and the simulated block environment of each blockchain account will isolate the scope of other accounts, thereby avoiding the mutual influence caused by the simulated transactions of different blockchain accounts, which is conducive to ensuring the uniformity between the simulated block environment and the actual blockchain and improving the accuracy of the simulation results.
[0120] In some optional embodiments, before obtaining a simulated transaction request from a blockchain account, the simulation system obtains and locally saves the latest block data of the latest block in the blockchain, and further monitors the block chain operation in the blockchain. When a new block is chained in the blockchain, the new block is obtained and the latest block data saved locally is updated according to the new block to generate a simulated block environment for the blockchain. The timeliness of the latest block data in the simulation system is ensured by saving the latest block data and monitoring the blocks on the chain to update the local data, and by pre-reading the data from the blockchain and storing it locally in the simulation system, compared to reading data from the blockchain during the generation of the simulated block environment, the impact of the communication process on the generation process can be reduced, and the failure of the simulated transaction process caused by communication failure can be avoided, thereby improving the reliability of the solution.
[0121] In the embodiments of the present application, it is also proposed to Figure 6 Other embodiments that refine the technical solution of the embodiment shown in the figure are as follows Figure 8 As shown, in a simulation method of blockchain transactions in one embodiment of the present application, a method for processing virtual resources may include the following steps:
[0122] Step S810, obtaining a simulated transaction request of a blockchain account, wherein the simulated transaction request includes multiple sets of transaction information.
[0123] Optionally, the implementation details of step S810 are the same as Figure 4 The simulation system performs simulation on each set of transaction information, and thus simulates the data status after executing multiple blockchain transactions.
[0124] Step S820, in response to the simulated transaction request, performing a blockchain fork operation according to the latest block of the blockchain to generate a forked block, and establishing a simulated block environment of the blockchain according to the forked block.
[0125] Optionally, the implementation details of step S820 are the same as Figure 4 The step S420 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0126] Step S830: Determine the transaction type of the simulated transaction request according to the transaction information in the simulated transaction request.
[0127] Optionally, the implementation details of step S830 are the same as Figure 6The step S630 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0128] Step S840, the account addresses of the two parties in each set of transaction information and the transaction amount of virtual resources in the blockchain are respectively input into the simulation transaction interface corresponding to the intra-chain transaction to perform a simulated transaction and update the blockchain data of the forked block in the simulated block environment and return the simulated transaction result of the simulated transaction request through the simulation transaction interface, wherein the simulation transaction result includes the transaction result data of each set of transaction information in the simulated transaction environment.
[0129] In this embodiment, for multiple groups of transaction information in the simulated transaction request, the simulation system can be processed in a parallel manner, and the account addresses of the two parties in the blockchain and the virtual resource transaction volume in each group of transaction information are respectively input into the simulated transaction interface corresponding to the intra-chain transaction. When the simulation system receives each group of transaction information through the simulated transaction interface, it performs simulated transactions based on the blockchain data of the forked block in the simulated block environment, and the transaction result data of the simulated transaction corresponding to each group of transaction information are comprehensively merged to obtain the simulated transaction result and return it to the control thread through the simulated transaction interface. After performing the simulated transaction, the simulation system updates the transaction result to the blockchain data of the forked block in the simulated block environment. For example, the virtual resource balance of blockchain account A is 100, 10 units of virtual resources are transferred from blockchain account A in one simulated transaction, and 20 units of virtual resources are transferred from blockchain account A in another simulated transaction. In these two transactions, the starting balance of blockchain account A is 100, and the virtual resource balance of blockchain account A in the transaction results is 90 and 80 respectively. By processing multiple sets of transaction information in parallel, there is no need for multiple simulated transactions to wait for each other, thereby reducing the overall time consumption of simulated transactions and improving simulation efficiency.
[0130] Step S850, according to the smart contract address, smart contract call parameters and account address in the simulated transaction request, call the simulated transaction interface corresponding to the cross-chain transaction to perform a simulated transaction and update the blockchain data of the forked block in the simulated block environment.
[0131] Optionally, the implementation details of step S850 are the same as Figure 6 It is understood that, for the case of simulating multiple transactions at the same time, the specific implementation process of calling the simulated transaction interface corresponding to the cross-chain transaction is the same as the above-mentioned method of calling the simulated transaction interface corresponding to the intra-chain transaction, but the organization form of the input parameters is adjusted according to the specific information required when calling the interface.
[0132] Step S860, generating a simulation result of a blockchain transaction according to the data changes in the simulated block environment.
[0133] Optionally, the implementation details of step S860 are the same as Figure 4 The step S440 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0134] In the embodiment of the present application, during the process of simulating transactions, a simulated block environment of the blockchain is first generated according to the transaction logic information corresponding to the blockchain and the data of the latest block in the blockchain, and then a simulated transaction is performed in the simulated block environment, and then a simulated result of the blockchain transaction is generated according to the data changes in the simulated block environment. By performing simulated transactions in a simulated real environment, the data difference between the simulated blockchain and the actual blockchain is eliminated, and the degree of simulation of the simulated transaction is improved.
[0135] In some optional embodiments, in the process of generating the simulation results of blockchain transactions according to the data changes in the simulated block environment, the simulation system specifically obtains the simulation transaction results returned by the simulation transaction interface through the simulation transaction interface. The simulation transaction results will include the data changes involved in the simulation transaction interface in the process of executing the simulation transaction, such as the change in virtual resources of the relevant account, the smart contract call information, and the log information output during the transaction. The simulation system obtains the virtual resource transaction volume in the simulation transaction, the smart contract information called by the simulation transaction, and the log data output by the called smart contract from the simulation transaction results to obtain the simulation results of the blockchain transaction. In the case of cross-chain transactions, in addition to obtaining the changes in the virtual resources of the account, the called smart contract information and the log data output by the called smart contract will be further obtained, which is conducive to improving the information integrity in the simulation results.
[0136] In some optional embodiments, there is a corresponding relationship between the simulated block environment generated in response to the simulated transaction request of the blockchain account and the blockchain account, and the simulation system will also obtain the simulated transaction request of other blockchain accounts, and in response to the simulated transaction request of other blockchain accounts, generate other simulated block environments corresponding to other blockchain accounts according to the transaction logic information corresponding to the blockchain and the data of the latest block in the blockchain. After generating the simulation result of the blockchain transaction according to the data changes in the simulated block environment, if the simulated transaction request of the blockchain account is received, the simulated transaction request is executed in the simulated block environment corresponding to the blockchain account; and if the simulated transaction request of other blockchain accounts is received, the simulated transaction request is executed in the other simulated block environment corresponding to the blockchain account. That is to say, for each blockchain account, a simulated block environment is generated separately, and the simulated block environment of each blockchain account will isolate the scope of other accounts, thereby avoiding the mutual influence caused by the simulated transactions of different blockchain accounts, which is conducive to ensuring the uniformity between the simulated block environment and the actual blockchain and improving the accuracy of the simulation results.
[0137] In some optional embodiments, before obtaining a simulated transaction request from a blockchain account, the simulation system obtains and locally saves the latest block data of the latest block in the blockchain, and further monitors the block chain operation in the blockchain. When a new block is chained in the blockchain, the new block is obtained and the latest block data saved locally is updated according to the new block to generate a simulated block environment for the blockchain. The timeliness of the latest block data in the simulation system is ensured by saving the latest block data and monitoring the blocks on the chain to update the local data, and by pre-reading the data from the blockchain and storing it locally in the simulation system, compared to reading data from the blockchain during the generation of the simulated block environment, the impact of the communication process on the generation process can be reduced, and the failure of the simulated transaction process caused by communication failure can be avoided, thereby improving the reliability of the solution.
[0138] In the embodiments of the present application, it is also proposed to Figure 6 Other embodiments that refine the technical solution of the embodiment shown in the figure are as follows Fig. 9 As shown, in a simulation method of blockchain transactions in one embodiment of the present application, a method for processing virtual resources may include the following steps:
[0139] Step S910, obtaining a simulated transaction request of a blockchain account, wherein the simulated transaction request includes multiple sets of transaction information.
[0140] Optionally, the implementation details of step S910 are the same as Figure 4 The simulation system performs simulation on each set of transaction information, and thus simulates the data status after executing multiple blockchain transactions.
[0141] Step S920, in response to the simulated transaction request, performing a blockchain fork operation according to the latest block of the blockchain to generate a forked block, and establishing a simulated block environment of the blockchain according to the forked block.
[0142] Optionally, the implementation details of step S920 are the same as Figure 4 The step S420 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0143] Step S930: determining the transaction type of the simulated transaction request according to the transaction information in the simulated transaction request.
[0144] Optionally, the implementation details of step S930 are the same as Figure 6 The step S630 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0145] Step S940, according to the account addresses of the two parties to the transaction in the blockchain and the transaction volume of virtual resources in the multiple groups of transaction information, the simulated transaction interface corresponding to the intra-chain transaction is called in sequence to perform a simulated transaction and update the blockchain data of the forked block in the simulated block environment and return the simulated transaction result of the simulated transaction request through the simulated transaction interface, wherein the simulated transaction result includes the transaction result data of each group of transaction information in the simulated transaction environment.
[0146] Step S950, in the process of calling the simulated transaction interface corresponding to the intra-chain transaction according to each set of transaction information, for each set of transaction information, after obtaining the simulated transaction result corresponding to the previous set of transaction information through the simulated transaction interface, the simulated transaction interface corresponding to the intra-chain transaction is called according to the current transaction information.
[0147] In this embodiment, for multiple sets of transaction information in the simulated transaction request, the simulation system can process them in a serial manner, and call the simulated transaction interface corresponding to the intra-chain transaction in sequence according to the account addresses of the two parties in the blockchain and the transaction volume of virtual resources in the multiple sets of transaction information. In the process of calling the simulated transaction interface, the simulation system calls the simulated transaction interface corresponding to the intra-chain transaction according to the current transaction information after obtaining the simulated transaction result corresponding to the previous set of transaction information through the simulated transaction interface for each set of transaction information. In other words, after the simulated transaction of the previous set of transaction information is completed and its data changes have been applied to the simulated transaction environment, the simulated transaction is performed based on the next set of transaction information. For example, in a simulated transaction, the virtual resource balance of blockchain account A changes from 100 to 90. If 10 units of virtual resources are transferred from blockchain account A in the next simulated transaction, the virtual resource balance of blockchain account A changes from 90 to 80. By processing multiple sets of transaction information in series, it is beneficial to restore the specific process of multiple transactions on the blockchain and improve the simulation ability of the scheme.
[0148] Step S960, according to the smart contract address, smart contract call parameters and account address in the simulated transaction request, call the simulated transaction interface corresponding to the cross-chain transaction to perform a simulated transaction and update the blockchain data of the forked block in the simulated block environment.
[0149] Optionally, the implementation details of step S960 are the same as Figure 6It is understood that, for the case of simulating multiple transactions at the same time, the specific implementation process of calling the simulated transaction interface corresponding to the cross-chain transaction is the same as the above-mentioned method of calling the simulated transaction interface corresponding to the intra-chain transaction, but the organization form of the input parameters is adjusted according to the specific information required when calling the interface.
[0150] Step S970, generating a simulation result of a blockchain transaction according to the data changes in the simulated block environment.
[0151] Optionally, the implementation details of step S970 are the same as Figure 4 The step S440 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0152] In the embodiment of the present application, during the process of simulating transactions, a simulated block environment of the blockchain is first generated according to the transaction logic information corresponding to the blockchain and the data of the latest block in the blockchain, and then a simulated transaction is performed in the simulated block environment, and then a simulated result of the blockchain transaction is generated according to the data changes in the simulated block environment. By performing simulated transactions in a simulated real environment, the data difference between the simulated blockchain and the actual blockchain is eliminated, and the degree of simulation of the simulated transaction is improved.
[0153] In some optional embodiments, in the process of generating the simulation results of blockchain transactions according to the data changes in the simulated block environment, the simulation system specifically obtains the simulation transaction results returned by the simulation transaction interface through the simulation transaction interface. The simulation transaction results will include the data changes involved in the simulation transaction interface in the process of executing the simulation transaction, such as the change in virtual resources of the relevant account, the smart contract call information, and the log information output during the transaction. The simulation system obtains the virtual resource transaction volume in the simulation transaction, the smart contract information called by the simulation transaction, and the log data output by the called smart contract from the simulation transaction results to obtain the simulation results of the blockchain transaction. In the case of cross-chain transactions, in addition to obtaining the changes in the virtual resources of the account, the called smart contract information and the log data output by the called smart contract will be further obtained, which is conducive to improving the information integrity in the simulation results.
[0154] In some optional embodiments, there is a corresponding relationship between the simulated block environment generated in response to the simulated transaction request of the blockchain account and the blockchain account, and the simulation system will also obtain the simulated transaction request of other blockchain accounts, and in response to the simulated transaction request of other blockchain accounts, generate other simulated block environments corresponding to other blockchain accounts according to the transaction logic information corresponding to the blockchain and the data of the latest block in the blockchain. After generating the simulation result of the blockchain transaction according to the data changes in the simulated block environment, if the simulated transaction request of the blockchain account is received, the simulated transaction request is executed in the simulated block environment corresponding to the blockchain account; and if the simulated transaction request of other blockchain accounts is received, the simulated transaction request is executed in the other simulated block environment corresponding to the blockchain account. That is to say, for each blockchain account, a simulated block environment is generated separately, and the simulated block environment of each blockchain account will isolate the scope of other accounts, thereby avoiding the mutual influence caused by the simulated transactions of different blockchain accounts, which is conducive to ensuring the uniformity between the simulated block environment and the actual blockchain and improving the accuracy of the simulation results.
[0155] In some optional embodiments, before obtaining a simulated transaction request from a blockchain account, the simulation system obtains and locally saves the latest block data of the latest block in the blockchain, and further monitors the block chain operation in the blockchain. When a new block is chained in the blockchain, the new block is obtained and the latest block data saved locally is updated according to the new block to generate a simulated block environment for the blockchain. The timeliness of the latest block data in the simulation system is ensured by saving the latest block data and monitoring the blocks on the chain to update the local data, and by pre-reading the data from the blockchain and storing it locally in the simulation system, compared to reading data from the blockchain during the generation of the simulated block environment, the impact of the communication process on the generation process can be reduced, and the failure of the simulated transaction process caused by communication failure can be avoided, thereby improving the reliability of the solution.
[0156] In the embodiments of the present application, it is also proposed to Figure 4 Other embodiments that refine the technical solution of the embodiment shown in the figure are as follows Fig.10 As shown, in a simulation method of blockchain transactions in one embodiment of the present application, a method for processing virtual resources may include the following steps:
[0157] Step S1010, obtaining a simulated transaction request of a blockchain account.
[0158] Optionally, the implementation details of step S1010 are the same as Figure 4 The step S410 shown in FIG. 1 is consistent with the step S410 shown in FIG. 1 and will not be
[0159] Step S1020, in response to the simulated transaction request, performing a blockchain fork operation according to the latest block of the blockchain to generate a forked block, and establishing a simulated block environment of the blockchain according to the forked block.
[0160] Optionally, the implementation details of step S1020 are the same as Figure 4 The step S420 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0161] Step S1030, performing a simulated transaction in the simulated block environment according to the simulated transaction request.
[0162] Optionally, the implementation details of step S1030 are the same as Figure 4 The step S430 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0163] Step S1040, generating a simulation result of a blockchain transaction according to the data changes in the simulated block environment.
[0164] Optionally, the implementation details of step S1040 are the same as Figure 4 The step S440 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0165] Step S1050: receiving a result confirmation message for the simulation result.
[0166] The result confirmation message is usually sent by the client that logs in to the blockchain account. The client displays the simulation result to the simulation requester. The simulation requester can confirm or not confirm the simulation result. When the simulation result satisfies the simulation requester, the simulation requester can confirm it through the client, and the client sends a result confirmation message for the simulation result to the simulation system.
[0167] Step S1060, in response to the result confirmation message, packaging the simulated transaction information corresponding to the simulation result into a blockchain transaction.
[0168] Step S1070: Sign the blockchain transaction using a blockchain key.
[0169] After receiving the result confirmation message, the simulation system will package the simulated transaction information in the simulation result into a blockchain transaction according to the organizational form of the block in the blockchain. And the packaged blockchain transaction is signed by the blockchain key of the blockchain account of the simulation requester. At this point, the signed blockchain transaction has become a blockchain transaction that can be directly submitted to the chain. The blockchain key of the blockchain account can be obtained from the client through a separate authentication and key acquisition process, or the owner of the blockchain account can specify the storage address of the key in advance or obtain the blockchain key through a proxy contract.
[0170] Step S1080, the signed blockchain transaction is uploaded to the blockchain.
[0171] The simulation system can act as an agent of the blockchain account to submit the signed blockchain transaction to the blockchain. After the blockchain verifies and reaches consensus on the signed blockchain transaction, it packages the blockchain transaction into a new block and puts it on the chain. By confirming the message based on the result, the simulation result is put on the blockchain without re-executing the transaction process in the blockchain environment, which helps to reduce the consumption of computing resources and improve resource utilization.
[0172] In the embodiment of the present application, during the process of simulating transactions, a simulated block environment of the blockchain is first generated according to the transaction logic information corresponding to the blockchain and the data of the latest block in the blockchain, and then a simulated transaction is performed in the simulated block environment, and then a simulated result of the blockchain transaction is generated according to the data changes in the simulated block environment. By performing simulated transactions in a simulated real environment, the data difference between the simulated blockchain and the actual blockchain is eliminated, and the degree of simulation of the simulated transaction is improved.
[0173] In some optional embodiments, in response to the result confirmation message, in the process of packaging the simulated transaction information corresponding to the simulation result as a blockchain transaction, the simulation system responds to the result confirmation message, determines the simulated transaction information of the simulated transaction according to the transaction operation in the simulated transaction and the transaction data of the historical transaction corresponding to the transaction operation, and then packages the simulated transaction information into a blockchain transaction according to the information structure of the blockchain transaction in the blockchain. Specifically, in the transaction process of the blockchain, there is usually a specific data processing process for the transaction operation of each transaction, and these processing processes are usually the form and content requirements when the blockchain puts the transaction on the chain, such as the need to provide a transaction sequence number and the need to provide virtual resource consumption during the transaction process. For example, for a transaction, the blockchain will divide a part of the virtual resources from the virtual resources being traded according to a predetermined ratio and transfer it to the blockchain account that provides the computing amount required in the transaction operation, so the transaction data will change accordingly. Alternatively, when conducting a transaction, the blockchain will convert the virtual resources being traded according to a predetermined ratio, such as a time-related ratio or a ratio obtained from a third party. Alternatively, each simulated transaction needs to confirm a unique transaction identification information when it is sent to the blockchain, and the transaction identification information can be determined based on the transaction identification information of the historical transaction, such as a serial number. The simulation system can obtain the processes that need to be processed in these transaction operations from the transaction data of the historical transactions corresponding to the transaction operations, thereby confirming the simulated transaction information of the simulated transaction. The simulated transaction information is determined by the transaction operations in the simulated transaction and the transaction data of the historical transactions corresponding to the transaction operations, so that the packaged blockchain transactions can directly meet the requirements of the blockchain for transactions on the chain, which is conducive to improving the success rate of chaining.
[0174] In some optional embodiments, there is a corresponding relationship between the simulated block environment generated in response to the simulated transaction request of the blockchain account and the blockchain account, and the simulation system will also obtain the simulated transaction request of other blockchain accounts, and in response to the simulated transaction request of other blockchain accounts, generate other simulated block environments corresponding to other blockchain accounts according to the transaction logic information corresponding to the blockchain and the data of the latest block in the blockchain. After generating the simulation result of the blockchain transaction according to the data changes in the simulated block environment, if the simulated transaction request of the blockchain account is received, the simulated transaction request is executed in the simulated block environment corresponding to the blockchain account; and if the simulated transaction request of other blockchain accounts is received, the simulated transaction request is executed in the other simulated block environment corresponding to the blockchain account. That is to say, for each blockchain account, a simulated block environment is generated separately, and the simulated block environment of each blockchain account will isolate the scope of other accounts, thereby avoiding the mutual influence caused by the simulated transactions of different blockchain accounts, which is conducive to ensuring the uniformity between the simulated block environment and the actual blockchain and improving the accuracy of the simulation results.
[0175] In some optional embodiments, before obtaining a simulated transaction request from a blockchain account, the simulation system obtains and locally saves the latest block data of the latest block in the blockchain, and further monitors the block chain operation in the blockchain. When a new block is chained in the blockchain, the new block is obtained and the latest block data saved locally is updated according to the new block to generate a simulated block environment for the blockchain. The timeliness of the latest block data in the simulation system is ensured by saving the latest block data and monitoring the blocks on the chain to update the local data, and by pre-reading the data from the blockchain and storing it locally in the simulation system, compared to reading data from the blockchain during the generation of the simulated block environment, the impact of the communication process on the generation process can be reduced, and the failure of the simulated transaction process caused by communication failure can be avoided, thereby improving the reliability of the solution.
[0176] In the embodiments of the present application, it is also proposed to Figure 4 Other embodiments that refine the technical solution of the embodiment shown in the figure are as follows Fig.11 As shown, in a simulation method of blockchain transactions in one embodiment of the present application, a method for processing virtual resources may include the following steps:
[0177] Step S1110, obtaining a simulated transaction request of a blockchain account.
[0178] Optionally, the implementation details of step S1110 are the same as Figure 4 The step S410 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0179] Step S1120, in response to the simulated transaction request, performing a blockchain fork operation according to the latest block of the blockchain to generate a forked block, and establishing a simulated block environment of the blockchain according to the forked block.
[0180] Optionally, the implementation details of step S1120 are the same as Figure 4 The step S420 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0181] Step S1130, performing a simulated transaction in the simulated block environment according to the simulated transaction request.
[0182] Optionally, the implementation details of step S1130 are the same as Figure 4 The step S430 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0183] Step S1140, generating a simulation result of a blockchain transaction according to the data changes in the simulated block environment.
[0184] Optionally, the implementation details of step S1140 are the same as Figure 4 The step S440 shown in FIG. 1 is the same as that in FIG. 1 and will not be described in detail.
[0185] Step S1150: When a new block is generated in the blockchain, an on-chain transaction in the new block is obtained, where the on-chain transaction includes signature information of the transaction party account.
[0186] Step S1160, performing signature verification on the signature information in the on-chain transaction according to the key information of the transaction party account in the simulated transaction environment.
[0187] Step S1170: If the signature verification passes, the on-chain transaction in the new block is executed in the simulated transaction environment.
[0188] Specifically, the simulation system monitors the events or operations of the new block on the blockchain. When a new block is on the blockchain, the simulation system obtains the on-chain transaction in the new block from the blockchain, and the on-chain transaction contains the signature information of the transaction party's account. Subsequently, the simulation system verifies the signature information in the on-chain transaction according to the key information of the transaction party's account in the simulated transaction environment. Among them, the signature information of the transaction party's account is usually obtained by signing with its private key. The public key of the transaction party's account is obtained and stored in the simulation system together with the forked block as public information for signature verification. If the signature verification passes, the simulation system executes the on-chain transaction in the new block in the simulated transaction environment. In this embodiment, for the blockchain transaction synchronized from the blockchain, the key verification process will be performed on the transaction, and the transaction will be executed in the simulated transaction environment only after passing it. For the simulated transaction request, no verification is required, and it is directly executed in the simulated transaction environment, thereby simplifying the transaction process to improve the execution efficiency, and avoiding the data in the simulated transaction environment from being modified by the wrong transaction, thereby ensuring the security of the data used in the simulated transaction process.
[0189] In the embodiment of the present application, during the process of simulating transactions, a simulated block environment of the blockchain is first generated according to the transaction logic information corresponding to the blockchain and the data of the latest block in the blockchain, and then a simulated transaction is performed in the simulated block environment, and then a simulated result of the blockchain transaction is generated according to the data changes in the simulated block environment. By performing simulated transactions in a simulated real environment, the data difference between the simulated blockchain and the actual blockchain is eliminated, and the degree of simulation of the simulated transaction is improved.
[0190] In some optional embodiments, in the process of executing on-chain transactions in a new block in a simulated transaction environment, the simulation system will parse the on-chain transactions in the new block, obtain the transaction sequence value of the on-chain transactions, and then retrieve the transaction sequence value of the on-chain transactions in the simulated transactions in the simulated transaction environment. If there is a transaction sequence value of a historical simulated transaction that is the same as the transaction sequence value of the on-chain transaction, then according to the historical simulated transaction, the data changes caused by the historical simulated transaction are restored in the simulated transaction environment, and the on-chain transactions are executed in the simulated transaction environment. The conflicts between the transactions of the actual blockchain and the simulated transactions in the simulated transaction environment are identified through the transaction sequence value, and when there is a conflict, the data changes of the simulated transaction are restored to the state before the transaction, and then the on-chain transactions are executed in the simulated transaction environment, so as to ensure the consistency between the forked blocks in the simulated transaction environment and the latest blocks in the blockchain.
[0191] In some optional embodiments, there is a corresponding relationship between the simulated block environment generated in response to the simulated transaction request of the blockchain account and the blockchain account, and the simulation system will also obtain the simulated transaction request of other blockchain accounts, and in response to the simulated transaction request of other blockchain accounts, generate other simulated block environments corresponding to other blockchain accounts according to the transaction logic information corresponding to the blockchain and the data of the latest block in the blockchain. After generating the simulation result of the blockchain transaction according to the data changes in the simulated block environment, if the simulated transaction request of the blockchain account is received, the simulated transaction request is executed in the simulated block environment corresponding to the blockchain account; and if the simulated transaction request of other blockchain accounts is received, the simulated transaction request is executed in the other simulated block environment corresponding to the blockchain account. That is to say, for each blockchain account, a simulated block environment is generated separately, and the simulated block environment of each blockchain account will isolate the scope of other accounts, thereby avoiding the mutual influence caused by the simulated transactions of different blockchain accounts, which is conducive to ensuring the uniformity between the simulated block environment and the actual blockchain and improving the accuracy of the simulation results.
[0192] In some optional embodiments, before obtaining a simulated transaction request from a blockchain account, the simulation system obtains and locally saves the latest block data of the latest block in the blockchain, and further monitors the block chain operation in the blockchain. When a new block is chained in the blockchain, the new block is obtained and the latest block data saved locally is updated according to the new block to generate a simulated block environment for the blockchain. The timeliness of the latest block data in the simulation system is ensured by saving the latest block data and monitoring the blocks on the chain to update the local data, and by pre-reading the data from the blockchain and storing it locally in the simulation system, compared to reading data from the blockchain during the generation of the simulated block environment, the impact of the communication process on the generation process can be reduced, and the failure of the simulated transaction process caused by communication failure can be avoided, thereby improving the reliability of the solution.
[0193] The following is a detailed introduction to the specific implementation of the technical solution of this application in one embodiment. Fig.12 , Fig.12 FIG. 1 is a flowchart of a specific implementation of the simulation method of blockchain transactions in this application in one embodiment. Fig.12As shown in the figure, the simulation system monitors the blockchain data and pulls the latest data from the blockchain. At the same time, the local data is kept up to date based on the latest data. The account address and public key on the blockchain are public, and the private key is in the hands of the user. There is no user private key in the simulation system used for simulated transaction operations, so the simulation system must be modified based on the open source synchronization node code of each blockchain. The simulation system will skip the signature verification step for the received simulated transaction, but the on-chain transactions synchronized from each blockchain in real time will still be verified normally. After the simulation system is running, it will keep synchronizing the latest data of each chain.
[0194] When a user wants to simulate a transaction, he will initiate an interface call request. The simulation system receives the user's simulated transaction, identifies the blockchain selected by the user, and forks and isolates a new block at the latest block on the maintained blockchain. The simulated transactions submitted by the user are all run in this block. This environment belongs only to the user, and other users' access will be isolated. The original blockchain will continue to synchronize the latest block data. If a new user requests a simulation, it will continue to fork at the current latest new block. The simulated transactions submitted by the user are performed on the forked block, so it will not affect the synchronization of the blockchain maintained in the simulation system.
[0195] After isolating the forked block as a simulation environment, the simulation system will simulate transactions in the simulation environment. The simulation system supports continuous addition of transactions in a single block, such as parallel transactions or serial transactions. Parallel means that multiple transactions can be executed at the same time. Serial transactions are executed successfully on the blockchain. After the blockchain status is updated, the second transaction is simulated and the status can be continuously superimposed. Each time a user submits a simulated transaction, the result is returned after the operation is completed.
[0196] After executing the user's transaction, the simulation system needs to identify the assets transferred, the log events issued, and the calls made between contracts. The simulation system collects all of them and sends them to the user. Some users need to use logs to analyze the operation of smart contracts. On the official blockchain, logs and events are generated after the block is generated, so the logs can only be obtained by checking the transaction after the block is actually on the chain. However, the simulation system simulates through a simulation environment, and can immediately generate blocks and collect them and return them to the user. Event logs are generally pre-agreed in the smart contract, and the smart contract will issue them as long as the blockchain transaction call is triggered.
[0197] Users can observe whether the returned transaction impact results meet their expectations. If they do, they can export all submitted simulated transactions. When exporting, the simulation system will assemble the structure of the transaction to be signed. Because the simulation does not require information such as transaction fees and transaction sequence numbers, but the formal blockchain requires it, the simulation system will estimate the usage of historical simulated transaction fees, give the most reasonable transaction fees, check the transaction sequence number of the operating account and other things required for signature, and fill in the necessary parameters such as transaction sequence number and transaction fee. Return to the user, just use the corresponding private key signature of the initiator of the transaction to send it to the blockchain.
[0198] It should be noted that although the steps of the method in the present application are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0199] The following introduces the device implementation of the present application, which can be used to execute the simulation method of blockchain transactions in the above embodiments of the present application. Fig.13 The block diagram schematically shows the composition of the simulation device for blockchain transactions in the embodiment of the present application. Fig.13 As shown, the simulation device 1300 for blockchain transactions may mainly include:
[0200] An acquisition module 1310 is used to acquire a simulated transaction request;
[0201] A forking module 1320, configured to respond to the simulated transaction request, perform a blockchain forking operation according to the latest block of the blockchain to generate a forked block, and establish a simulated block environment of the blockchain according to the forked block;
[0202] A simulation module 1330, configured to perform a simulated transaction according to the simulated transaction request in the simulated block environment;
[0203] The generation module 1340 is used to generate a simulation result of the blockchain transaction according to the data changes in the simulated block environment.
[0204] In some embodiments of the present application, based on the above technical solution, the simulation module 1330 is also configured to: determine the transaction type of the simulated transaction request according to the transaction information in the simulated transaction request; if the transaction type of the simulated transaction request is an intra-chain transaction, then according to the account addresses of the transaction parties in the blockchain and the virtual resource transaction volume in the simulated transaction request, call the simulated transaction interface corresponding to the intra-chain transaction to perform a simulated transaction and update the blockchain data of the forked block in the simulated block environment; if the transaction type of the simulated transaction request is a cross-chain transaction, then according to the smart contract address, smart contract call parameters and account address in the simulated transaction request, call the simulated transaction interface corresponding to the cross-chain transaction to perform a simulated transaction and update the blockchain data of the forked block in the simulated block environment.
[0205] In some embodiments of the present application, based on the above technical solution, the generation module 1340 is also configured to: obtain, through the simulation transaction interface, the simulation transaction result returned by the simulation transaction interface; obtain from the simulation transaction result the virtual resource transaction volume in the simulation transaction, the smart contract information called by the simulation transaction, and the log data output by the called smart contract to obtain the simulation result of the blockchain transaction.
[0206] In some embodiments of the present application, based on the above technical solution, the simulation module 1330 is also configured to: check the virtual resource type in the simulated transaction request and the account addresses of the two parties to the transaction; if the simulated transaction request contains multiple virtual resource types or one of the account addresses of the two parties to the transaction is a smart contract address, then determine that the transaction type of the simulated transaction request is a cross-chain transaction; if the simulated transaction request contains a single virtual resource type and the account addresses of the two parties to the transaction are both account addresses in the blockchain, then determine that the transaction type of the simulated transaction request is an intra-chain transaction.
[0207] In some embodiments of the present application, the simulated transaction request includes multiple groups of transaction information. Based on the above technical solution, the simulation module 1330 is also configured to: input the account addresses of the two parties to the transaction in the blockchain and the transaction amount of virtual resources in each group of transaction information into the simulated transaction interface corresponding to the intra-chain transaction, so as to return the simulated transaction result of the simulated transaction request through the simulated transaction interface, wherein the simulated transaction result includes the transaction result data of each group of transaction information in the simulated transaction environment.
[0208] In some embodiments of the present application, the simulated transaction request includes multiple sets of transaction information. Based on the above technical solution, the simulation module 1330 is further configured to: sequentially call the simulated transaction interface corresponding to the intra-chain transaction according to the account addresses of the transaction parties in the blockchain and the transaction amount of virtual resources in the multiple sets of transaction information, so as to return the simulated transaction result corresponding to each set of transaction information through the simulated transaction interface;
[0209] In the process of calling the simulated transaction interface corresponding to the intra-chain transaction according to each set of transaction information, for each set of transaction information, after obtaining the simulated transaction result corresponding to the previous set of transaction information through the simulated transaction interface, the simulated transaction interface corresponding to the intra-chain transaction is called according to the current transaction information.
[0210] In some embodiments of the present application, based on the above technical solution, the simulation device for blockchain transactions further includes:
[0211] A receiving module, configured to receive a result confirmation message for the simulation result;
[0212] A packaging module, configured to package the simulated transaction information corresponding to the simulation result into a blockchain transaction in response to the result confirmation message;
[0213] A signing module, configured to sign the blockchain transaction using a blockchain key;
[0214] The on-chain module is configured to chain the signed blockchain transaction in the blockchain.
[0215] In some embodiments of the present application, based on the above technical solution, the packaging module is also configured to: in response to the result confirmation message, determine the simulated transaction information of the simulated transaction according to the transaction operations in the simulated transaction and the transaction data of the historical transactions corresponding to the transaction operations; and package the simulated transaction information into a blockchain transaction according to the information structure of the blockchain transaction in the blockchain.
[0216] In some embodiments of the present application, based on the above technical solution, the simulation device for blockchain transactions further includes:
[0217] A transaction acquisition module, configured to acquire, when a new block is generated in the blockchain, an on-chain transaction in the new block, wherein the on-chain transaction includes signature information of a transaction party account;
[0218] A signature verification module, configured to perform signature verification on the signature information in the on-chain transaction according to the key information of the transaction party account in the simulated transaction environment;
[0219] The transaction execution module is configured to execute the on-chain transaction in the new block in the simulated transaction environment if the signature verification is passed.
[0220] In some embodiments of the present application, based on the above technical solution, the transaction execution module is also configured to: parse the on-chain transactions in the new block to obtain the transaction sequence value of the on-chain transactions; retrieve the transaction sequence value of the on-chain transactions in the simulated transactions in the simulated transaction environment; if there is a historical simulated transaction with a transaction sequence value that is the same as the transaction sequence value of the on-chain transaction, then based on the historical simulated transactions, restore the data changes caused by the historical simulated transactions in the simulated transaction environment; and execute the on-chain transactions in the simulated transaction environment.
[0221] In some embodiments of the present application, based on the above technical solution, the simulated block environment corresponds to a blockchain account; the fork module 1320 is further configured to: obtain simulated transaction requests from other blockchain accounts; in response to the simulated transaction requests from the other blockchain accounts, perform a blockchain fork operation according to the latest block of the blockchain to obtain other forked blocks, and establish a simulated block environment corresponding to the other blockchain account according to the other forked blocks; the generation module 1340 is further configured to: if a simulated transaction request from the blockchain account is received, execute the simulated transaction request in the simulated block environment corresponding to the blockchain account; if a simulated transaction request from the other blockchain account is received, execute the simulated transaction request in the other simulated block environment corresponding to the blockchain account.
[0222] In some embodiments of the present application, based on the above technical solution, the acquisition module 1310 is also configured to: acquire and locally save the latest block data of the latest block in the blockchain; monitor the block chain operation in the blockchain; when a new block is chained in the blockchain, acquire the new block and update the latest block data saved locally according to the new block, so as to generate a simulated block environment of the blockchain.
[0223] It should be noted that the apparatus provided in the above embodiment and the method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module performs the operation has been described in detail in the method embodiment and will not be repeated here.
[0224] Fig.14 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown.
[0225] It should be noted that Fig.14 The computer system 1400 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0226] like Fig.14 As shown, the computer system 1400 includes a central processing unit (CPU) 1401, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1402 or the program loaded from the storage part 1408 to the random access memory (RAM) 1403. Various programs and data required for system operation are also stored in the RAM 1403. The CPU 1401, ROM 1402 and RAM 1403 are connected to each other through a bus 1404. An input / output (I / O) interface 1405 is also connected to the bus 1404.
[0227] The following components are connected to the I / O interface 1405: an input section 1406 including a keyboard, a mouse, etc.; an output section 1407 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1408 including a hard disk, etc.; and a communication section 1409 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1409 performs communication processing via a network such as the Internet. A drive 1410 is also connected to the I / O interface 1405 as needed. A removable medium 1411, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1410 as needed so that a computer program read therefrom is installed into the storage section 1408 as needed.
[0228] In particular, according to an embodiment of the present application, the process described in each method flow chart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part 1409, and / or installed from a removable medium 1411. When the computer program is executed by a central processing unit (CPU) 1401, various functions defined in the system of the present application are executed.
[0229] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a 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 of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0230] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions 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 a different order from the order 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 flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0231] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.
[0232] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation method of the present application 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, including several instructions to obtain 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 implementation method of the present application.
[0233] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary technical means in the art that are not disclosed in the present application.
[0234] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for simulating blockchain transactions, characterized in that: include: Get simulated transaction request; In response to the simulated transaction request, performing a blockchain fork operation according to the latest block of the blockchain to generate a forked block, and establishing a simulated block environment of the blockchain according to the forked block; Performing simulated transactions in the simulated block environment according to the simulated transaction request; According to the data changes in the simulated block environment, a simulation result of the blockchain transaction is generated.
2. The method for simulating blockchain transactions according to claim 1, characterized in that: The performing a simulated transaction according to the simulated transaction request in the simulated block environment includes: Determining the transaction type of the simulated transaction request according to the transaction information in the simulated transaction request; If the transaction type of the simulated transaction request is an intra-chain transaction, then according to the account addresses of the two parties to the transaction in the blockchain and the transaction amount of virtual resources in the simulated transaction request, the simulated transaction interface corresponding to the intra-chain transaction is called to perform a simulated transaction and update the blockchain data of the forked block in the simulated block environment; If the transaction type of the simulated transaction request is a cross-chain transaction, the simulated transaction interface corresponding to the cross-chain transaction is called according to the smart contract address, smart contract call parameters and account address in the simulated transaction request to perform a simulated transaction and update the blockchain data of the forked block in the simulated block environment.
3. The method for simulating blockchain transactions according to claim 2, characterized in that: Generating a simulation result of a blockchain transaction according to the data changes in the simulated block environment includes: Obtaining the simulated transaction result returned by the simulated transaction interface through the simulated transaction interface; The transaction volume of virtual resources in the simulated transaction, the smart contract information called by the simulated transaction, and the log data output by the called smart contract are obtained from the simulated transaction result to obtain the simulation result of the blockchain transaction.
4. The method for simulating blockchain transactions according to claim 2, characterized in that: The step of determining the transaction type of the simulated transaction request according to the transaction information in the simulated transaction request includes: Checking the virtual resource type and the account addresses of both parties in the simulated transaction request; If the simulated transaction request contains multiple virtual resource types or one of the account addresses of the two transaction parties is a smart contract address, then the transaction type of the simulated transaction request is determined to be a cross-chain transaction; If the simulated transaction request contains a single virtual resource type and the account addresses of both parties to the transaction are account addresses in the blockchain, then the transaction type of the simulated transaction request is determined to be an intra-chain transaction.
5. The method for simulating blockchain transactions according to claim 2, characterized in that: The simulated transaction request includes multiple groups of transaction information; calling the simulated transaction interface corresponding to the intra-chain transaction according to the account addresses of the transaction parties in the blockchain and the transaction amount of virtual resources in the simulated transaction request includes: The account addresses of the two parties to the transaction in the blockchain and the transaction amount of virtual resources in each set of transaction information are respectively input into the simulated transaction interface corresponding to the intra-chain transaction, so as to return the simulated transaction result of the simulated transaction request through the simulated transaction interface, wherein the simulated transaction result includes the transaction result data of each set of transaction information conducted in the simulated transaction environment.
6. The method for simulating blockchain transactions according to claim 2, characterized in that: The simulated transaction request includes multiple groups of transaction information; calling the simulated transaction interface corresponding to the intra-chain transaction according to the account addresses of the transaction parties in the blockchain and the transaction amount of virtual resources in the simulated transaction request includes: The simulated transaction interface corresponding to the intra-chain transaction is sequentially called according to the account addresses of the transaction parties in the blockchain and the transaction amount of virtual resources in the multiple sets of transaction information, so as to return the simulated transaction result corresponding to each set of transaction information through the simulated transaction interface; In the process of calling the simulated transaction interface corresponding to the intra-chain transaction according to each set of transaction information, for each set of transaction information, after obtaining the simulated transaction result corresponding to the previous set of transaction information through the simulated transaction interface, the simulated transaction interface corresponding to the intra-chain transaction is called according to the current transaction information.
7. The method for simulating blockchain transactions according to claim 1, characterized in that: After generating the simulation result of the blockchain transaction according to the data changes in the simulated block environment, the method further includes: receiving a result confirmation message for the simulation result; In response to the result confirmation message, packaging the simulated transaction information corresponding to the simulation result into a blockchain transaction; Signing the blockchain transaction by means of a blockchain key; The signed blockchain transaction is uploaded to the blockchain.
8. The method for simulating blockchain transactions according to claim 7, characterized in that: The step of packaging the simulated transaction information corresponding to the simulation result into a blockchain transaction in response to the result confirmation message includes: In response to the result confirmation message, determining simulated transaction information of the simulated transaction according to the transaction operation in the simulated transaction and the transaction data of the historical transaction corresponding to the transaction operation; According to the information structure of the blockchain transaction in the blockchain, the simulated transaction information is packaged into a blockchain transaction.
9. The method for simulating blockchain transactions according to claim 1, characterized in that: After performing a blockchain forking operation according to the latest block of the blockchain to generate a forked block in response to the simulated transaction request, and establishing a simulated block environment of the blockchain according to the forked block, the method further includes: When a new block is generated in the blockchain, an on-chain transaction in the new block is obtained, wherein the on-chain transaction includes signature information of the transaction party account; Perform signature verification on the signature information in the on-chain transaction according to the key information of the transaction party account in the simulated transaction environment; If the signature verification is successful, the on-chain transaction in the new block is executed in the simulated transaction environment.
10. The method for simulating blockchain transactions according to claim 9, characterized in that: Executing the on-chain transaction in the new block in the simulated transaction environment includes: Parsing the on-chain transactions in the new block to obtain the transaction sequence value of the on-chain transactions; Retrieving the transaction sequence value of the on-chain transaction in the simulated transaction in the simulated transaction environment; If there is a historical simulated transaction with a transaction sequence value that is the same as the transaction sequence value of the on-chain transaction, then according to the historical simulated transaction, restore the data changes caused by the historical simulated transaction in the simulated transaction environment; The on-chain transaction is executed in the simulated transaction environment.
11. The method for simulating blockchain transactions according to claim 1, characterized in that: The simulated block environment corresponds to a blockchain account; the method further comprises: Get simulated transaction requests from other blockchain accounts; In response to the simulated transaction request of the other blockchain account, performing a blockchain fork operation according to the latest block of the blockchain to obtain other forked blocks, and establishing a simulated block environment corresponding to the other blockchain account according to the other forked blocks; After generating a simulation result of a blockchain transaction according to the data changes in the simulated block environment, the method further includes: If a simulated transaction request of the blockchain account is received, executing the simulated transaction request in the simulated block environment corresponding to the blockchain account; If a simulated transaction request from the other blockchain account is received, the simulated transaction request is executed in the other simulated block environment corresponding to the blockchain account.
12. The method for simulating blockchain transactions according to claim 1, characterized in that: Before obtaining the simulated transaction request of the blockchain account, the method further includes: Obtain and locally save the latest block data of the latest block in the blockchain; Monitoring block on-chain operations in the blockchain; When a new block is added to the blockchain, the new block is obtained and the latest block data stored locally is updated according to the new block to generate a simulated block environment of the blockchain.
13. A simulation device for blockchain transactions, characterized in that: include: The acquisition module is used to obtain simulated transaction requests; A forking module, configured to respond to the simulated transaction request, perform a blockchain forking operation according to the latest block of the blockchain to generate a forked block, and establish a simulated block environment of the blockchain according to the forked block; A simulation module, used for performing a simulated transaction according to the simulated transaction request in the simulated block environment; The generation module is used to generate a simulation result of the blockchain transaction according to the data changes in the simulated block environment.
14. An electronic device, characterized in that: include: processor; A memory, configured to store executable instructions of the processor; Wherein, the processor is configured to execute the simulation method of blockchain transactions described in any one of claims 1 to 12 by executing the executable instructions.
15. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the simulation method of blockchain transactions as described in any one of claims 1 to 12 is implemented.
16. A computer program product, characterized in that The computer program product includes computer instructions, which are stored in a computer-readable storage medium. A processor of a computer device reads and executes the computer instructions from the computer-readable storage medium, so that the computer device performs the simulation method of blockchain transactions as described in any one of claims 1 to 12.
