Transaction aggregation method and system of block chain, terminal and storage medium
By receiving and merging transaction tasks on the blockchain to generate aggregated transaction credentials, the problem of low efficiency in smart contract transactions is solved, improving the transaction processing efficiency of the blockchain and reducing costs.
Patent Information
- Application Number
- CN202411361566.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2025-02-11
AI Technical Summary
The efficiency of smart contracts on the blockchain is limited and cannot meet user needs.
By receiving transaction tasks, identifying aggregateable transaction tasks based on pre-configured transaction classification rules, caching them in the transaction pool, merging them into aggregated transaction tasks, sending them to the blockchain node, and generating and saving aggregated transaction credentials.
It reduces the burden on the blockchain, improves transaction processing efficiency, reduces gas consumption, and reduces contract operation costs.
Smart Images

Figure CN119417466A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of blockchain, and specifically relates to a transaction aggregation method, system, terminal and storage medium of blockchain. Background Art
[0002] Blockchain: A new distributed infrastructure and computing paradigm that uses block chain data structures to verify and store data, distributed node consensus algorithms to generate and update data, cryptography to ensure the security of data transmission and access, and smart contracts composed of automated script codes to program and operate data.
[0003] Smart Contract: An automated computer program that runs on a blockchain and is used to perform predefined actions under the terms of a contract. These contracts are stored on the blockchain in the form of code and can be automatically executed by nodes on the blockchain. Smart contracts have a variety of applications on the blockchain, including digital currency transactions, identity verification, voting, supply chain management, and more.
[0004] Smart contracts are widely used on blockchain, but their efficiency is limited by blockchain performance and often cannot meet user needs. Summary of the invention
[0005] In view of the above-mentioned deficiencies in the prior art, the present invention provides a transaction aggregation method, system, terminal and storage medium of a blockchain to solve the above-mentioned technical problems.
[0006] In a first aspect, the present invention provides a transaction aggregation method for a blockchain, comprising: Receiving a transaction task, and confirming whether the transaction task is an aggregatable transaction task based on a pre-configured transaction classification rule; Cache aggregatable transaction tasks into a pre-built transaction pool; Merging multiple transaction tasks in the transaction pool into an aggregated transaction task, and sending the aggregated transaction task to a blockchain node so that the blockchain node executes the aggregated transaction task; Obtain multiple transaction vouchers returned by the blockchain node, and generate an aggregated transaction voucher based on the multiple transaction vouchers; The aggregated transaction voucher is saved to the evidence storage node.
[0007] In an optional implementation, receiving a transaction task, and confirming whether the transaction task is an aggregatable transaction task based on a preconfigured transaction classification rule, includes: Pre-configure transaction classification rules, wherein the transaction classification rules define aggregable transaction categories, and smart contract information and user role categories corresponding to the aggregable transaction categories, wherein the aggregable transaction categories include voucher transactions and bookkeeping transactions, and the smart contract information corresponding to the aggregable transaction categories includes the smart contract name and address; Extracting the smart contract name and address, as well as the transaction data with digital signature from the transaction task; Obtaining user information by parsing the digital signature, and obtaining the user role category based on the user information; Match the smart contract name and address obtained from the transaction task, as well as the user role category with the transaction classification rules; If the match is successful, the transaction task is determined to be an aggregatable transaction task; If the matching fails, the transaction task is determined to be a common transaction task.
[0008] In an optional implementation, after caching the aggregatable transaction tasks into a pre-built transaction pool, the method further includes: Monitor the number of transaction tasks in the transaction pool and the execution waiting time, where the execution waiting time is the time from the current moment to the last execution of the transaction task; If the number of the transaction tasks reaches a set task threshold or the execution waiting time reaches a set time threshold, the combined execution of the transaction tasks in the transaction pool is triggered.
[0009] In an optional implementation, merging multiple transaction tasks in the transaction pool into an aggregated transaction task, and sending the aggregated transaction task to a blockchain node so that the blockchain node executes the aggregated transaction task, includes: Get the waiting time of each transaction task in the transaction pool and filter out the longest waiting time; Determine whether the longest waiting time exceeds a preset waiting threshold: If yes, the transaction task to which the longest waiting time belongs is taken as the core transaction task, and the associated transaction tasks with the same smart contract as the core transaction task are selected from the transaction pool, and the core transaction task and the associated transaction tasks are merged into an aggregated transaction task; If not, the number of smart contracts and tasks corresponding to each smart contract is counted, and the smart contract with the largest number of tasks is used as the target smart contract, and multiple transaction tasks corresponding to the target smart contract are merged into one aggregated transaction task.
[0010] In an optional implementation, obtaining multiple transaction vouchers returned by a blockchain node and generating an aggregated transaction voucher based on the multiple transaction vouchers includes: Combining multiple transaction vouchers into one voucher data and recording the number of transaction vouchers included in the voucher data; Saving the credential data to a storage node; Calculate the MD5 value of the credential data; The transaction voucher quantity is added to the end of the MD5 value to obtain an aggregated transaction voucher.
[0011] In an optional embodiment, the method further comprises: receiving a query task, and extracting target data from the query task; Determine whether the implementation target data conforms to the format of the transaction voucher: If so, the query task is determined to be a common query task, and the common query task is sent to the blockchain node, and the query task is directly executed by the blockchain node; If not, extract the target MD5 value and the target number of transaction vouchers from the target data in the format of the aggregated transaction voucher, query the existing node for voucher data that completely matches the target MD5 value and the target number of transaction vouchers, and disassemble the voucher data into multiple transaction vouchers, and send the multiple transaction vouchers to the blockchain node to execute the query task.
[0012] In a second aspect, the present invention provides a blockchain transaction aggregation system, comprising: A transaction identification module, used for receiving a transaction task and confirming whether the transaction task is an aggregatable transaction task based on a pre-configured transaction classification rule; The transaction cache module is used to cache the aggregatable transaction tasks into a pre-built transaction pool; A transaction aggregation module, used to merge multiple transaction tasks in the transaction pool into an aggregated transaction task, and send the aggregated transaction task to a blockchain node so that the blockchain node executes the aggregated transaction task; A voucher processing module, used to obtain multiple transaction vouchers returned by the blockchain node, and generate an aggregated transaction voucher based on the multiple transaction vouchers; The certificate saving module is used to save the aggregate transaction certificate to the evidence storage node.
[0013] In an optional implementation, the transaction identification module includes: A rule configuration unit, used to pre-configure a transaction classification rule, wherein the transaction classification rule defines aggregatable transaction categories, and smart contract information and user role categories corresponding to the aggregatable transaction categories, wherein the aggregatable transaction categories include voucher transactions and bookkeeping transactions, and the smart contract information corresponding to the aggregatable transaction categories includes a smart contract name and address; An information extraction unit, used to extract the smart contract name and address, and transaction data with a digital signature from the transaction task; A signature parsing unit, used to obtain user information by parsing the digital signature, and obtain a user role category based on the user information; A rule matching unit, used to match the smart contract name and address obtained from the transaction task, and the user role category with the transaction classification rule; A first determination unit, configured to determine that the transaction task is an aggregatable transaction task if the matching is successful; The second determination unit is configured to determine that the transaction task is a common transaction task if the matching fails.
[0014] In a third aspect, a terminal is provided, including: processor, memory, wherein: The memory is used to store computer programs. The processor is used to call and run the computer program from the memory, so that the terminal executes the above-mentioned terminal method.
[0015] According to a fourth aspect, a computer storage medium is provided, wherein the computer-readable storage medium stores instructions, and when the instructions are executed on a computer, the computer executes the methods described in the above aspects.
[0016] The beneficial effect of the present invention is that the transaction aggregation method, system, terminal and storage medium of the blockchain provided by the present invention, by aggregating multiple transaction contents of smart contracts into one transaction according to preset logic, reduces the burden of the blockchain without intrusion and improves the blockchain tps in disguised form; at the same time, since multiple transactions are aggregated into one transaction, the number of operations is reduced, the amount of gas consumed is reduced, and the cost for the contract operator is reduced.
[0017] In addition, the invention has a reliable design principle, a simple structure and a very broad application prospect. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0019] Figure 1 is a schematic flow chart of a method according to an embodiment of the present invention.
[0020] Figure 2 is another schematic flow chart of a method according to an embodiment of the present invention.
[0021] Figure 3 The figure is a schematic flow chart of common transaction processing of a method according to an embodiment of the present invention.
[0022] Figure 4 It is a schematic flow chart of the query process of the method according to an embodiment of the present invention.
[0023] Figure 5 is a schematic block diagram of a system according to an embodiment of the present invention.
[0024] Figure 6 A schematic diagram of the structure of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0026] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.
[0027] The transaction aggregation method of blockchain provided in the embodiment of the present invention is executed by a computer device, and accordingly, the transaction aggregation system of blockchain runs in the computer device.
[0028] Figure 1 is a schematic flow chart of a method according to an embodiment of the present invention. Figure 1 The execution subject can be a blockchain transaction aggregation system. According to different requirements, the order of the steps in the flowchart can be changed, and some can be omitted.
[0029] like Figure 1 As shown, the method includes: Step 110, receiving a transaction task, and confirming whether the transaction task is an aggregatable transaction task based on a pre-configured transaction classification rule; Step 120, caching the aggregatable transaction tasks into a pre-built transaction pool; Step 130, merging multiple transaction tasks in the transaction pool into an aggregated transaction task, and sending the aggregated transaction task to a blockchain node so that the blockchain node executes the aggregated transaction task; Step 140, obtaining multiple transaction vouchers returned by the blockchain node, and generating an aggregated transaction voucher based on the multiple transaction vouchers; Step 150, save the aggregated transaction voucher to a storage node.
[0030] To facilitate understanding of the present invention, the transaction aggregation method of the blockchain provided by the present invention is further described below based on the principle of the transaction aggregation method of the blockchain of the present invention and the process of aggregating transaction tasks in the embodiment.
[0031] For details, please refer to Figure 2 , the transaction aggregation method of the blockchain includes: S1. Transaction task identification.
[0032] Pre-configure transaction classification rules, the transaction classification rules define aggregable transaction categories, and smart contract information and user role categories corresponding to the aggregable transaction categories, the aggregable transaction categories include voucher transactions and accounting transactions, and the smart contract information corresponding to the aggregable transaction categories includes smart contract names and addresses; extract the smart contract name and address, and transaction data with digital signatures from the transaction tasks; obtain user information by parsing the digital signatures, and obtain the user role category based on the user information; match the smart contract name and address, and the user role category obtained from the transaction tasks with the transaction classification rules; if the match is successful, determine the transaction task to be an aggregable transaction task; if the match fails, determine the transaction task to be an ordinary transaction task.
[0033] Specifically, the aggregation system needs to save the public and private keys of the transaction initiator of the collection transaction in advance, and also needs to set the binary data and address of the smart contract of the collection transaction. The smart contract of the collection transaction should meet some conditions. First, it has an interface for batch processing transactions; second, the business is merged and does not affect the business. Common vouchers and accounting transactions meet these conditions.
[0034] First, pre-configuring transaction classification rules is a key step, which requires system administrators or developers to clarify which transaction types should be classified as aggregatable based on business needs, and to set in detail the correspondence between these transaction types and smart contracts and user roles. This step not only limits voucher transactions (such as certificate issuance, equity transfer, etc.) and accounting transactions (such as financial records, asset changes, etc.) as aggregatable transaction categories, but may also include transaction types in other specific business scenarios, such as supply chain transactions, loan agreements, etc.
[0035] For the smart contract information and user role categories corresponding to the aggregatable transaction categories, in addition to the name and address of the smart contract, detailed information such as the version number, calling interface specification, and execution conditions of the smart contract may also be included to ensure the accurate execution and compliance of the transaction. User role categories are divided according to business logic, such as initiator, reviewer, executor, observer, etc. Different roles have different permissions and responsibilities in the transaction process.
[0036] In the process of extracting information from transaction tasks, the system not only captures the name and address of the smart contract, but also verifies the validity of the digital signature to ensure the integrity and immutability of the transaction data. The user information contained in the digital signature (such as public key, certificate, etc.) will be used for subsequent user identity authentication and role determination.
[0037] After parsing the digital signature to obtain user information, the system confirms the user's true identity by comparing it with the pre-stored user database or identity records on the blockchain, and automatically determines the user's role category in the current transaction task based on preset rules or algorithms. This step is crucial to ensuring the security and compliance of transactions.
[0038] When matching transaction classification rules, the system will compare the smart contract information and user role categories extracted from the transaction task with the pre-set transaction classification rules one by one. The matching process may involve complex logical judgments, such as checking whether the smart contract has been activated, whether the user role meets the transaction requirements, whether the transaction data conforms to a specific format, etc. If all conditions are met, the transaction task is determined to be an aggregatable transaction task and is prepared to be included in the corresponding aggregation processing flow; if any condition is not met, it is determined to be an ordinary transaction task and is processed according to the normal process.
[0039] Finally, for aggregatable transaction tasks, the system may perform batch processing, optimize execution order, reduce transaction costs, and other operations according to business needs to improve transaction processing efficiency and reduce costs. For ordinary transaction tasks, they are processed one by one according to the established business process.
[0040] The entire process is designed to improve the flexibility and efficiency of blockchain transactions while ensuring the security and compliance of transactions.
[0041] S2. Common transaction task processing methods such as Figure 3 As shown, including: S201 The user sends a non-aggregatable smart contract transaction to the aggregation system, including the user's own private key signature on the transaction; S202 The aggregation system determines that the transaction is non-aggregatable based on the contract method, address and sender signature; The S203 aggregation system directly sends transactions to blockchain nodes; S204 blockchain node accepts the transaction; S205 The blockchain node sends the transaction credentials to the aggregation system; S206 The aggregation system returns the transaction credential to the user; S207 blockchain consensus is completed and blocks are generated to record transactions.
[0042] S3. The processing method of the aggregatable transaction task includes: S301. The user sends an aggregatable smart contract transaction to the aggregation system, including the user's own private key signature on the transaction S302 The aggregation system determines that the transaction is aggregatable through the contract method, address and sender signature; The S303 aggregation system adds the transaction to its own transaction pool; S304 The aggregation system generates an aggregation transaction voucher and returns it to the user; S305 When the specified time interval or the specified number of transactions in the transaction aggregation pool is reached, the aggregation system merges the contents of the aggregated transaction pool into one transaction; Monitor the number of transaction tasks in the transaction pool and the execution waiting time, where the execution waiting time is the time between the current moment and the last execution of a transaction task; if the number of transaction tasks reaches a set task threshold or the execution waiting time reaches a set time threshold, trigger the merged execution of the transaction tasks in the transaction pool.
[0043] Get the waiting time of each transaction task in the transaction pool and filter out the longest waiting time; Determine whether the longest waiting time exceeds a preset waiting threshold: if so, take the transaction task to which the longest waiting time belongs as the core transaction task, screen out the associated transaction tasks whose smart contracts are the same as the core transaction tasks from the transaction pool, and merge the core transaction tasks and the associated transaction tasks into an aggregated transaction task; if not, count the number of smart contracts and tasks corresponding to each smart contract, take the smart contract with the largest number of tasks as the target smart contract, and merge multiple transaction tasks corresponding to the target smart contract into an aggregated transaction task.
[0044] The specific process includes the following: (1) Monitoring the transaction pool status and triggering the merging mechanism: The system continuously monitors the number of transaction tasks in the transaction pool and the execution waiting time of each transaction task. The execution waiting time is defined as the length of time that the task has not been executed from the time the transaction task was added to the transaction pool to the current moment. When the number of tasks in the transaction pool reaches the preset task threshold (such as a certain number of transaction tasks accumulated), or the execution waiting time of any transaction task exceeds the set time threshold (such as the waiting time exceeds a certain period of time without being executed), the system will automatically trigger the merging execution mechanism. This mechanism is designed to optimize transaction processing efficiency and reduce resource waste caused by too many transaction tasks or too long waiting time.
[0045] (2) Identify the transaction task with the longest waiting time: Once the merge execution mechanism is triggered, the system will first traverse all transaction tasks in the transaction pool, obtain the waiting time of each task, and filter out the transaction task with the longest waiting time. This transaction task with the longest waiting time will be regarded as a potential merge core because it may have a greater impact on users or system performance due to long-term non-processing.
[0046] (3) Merging logic based on the longest waiting time: Next, the system determines whether the longest waiting time exceeds the preset waiting threshold. If it exceeds, it means that the task needs to be processed urgently, so it is treated as a core transaction task. Subsequently, the system will filter out all associated transaction tasks that use the same smart contract as the core transaction task from the transaction pool. Because these tasks involve the same business logic and smart contract execution, they can be safely merged into an aggregated transaction task to reduce the number of executions and improve processing efficiency.
[0047] (4) Merging logic based on the number of tasks (alternative solution): If the longest waiting time does not exceed the preset waiting threshold, or the system chooses not to merge based on the longest waiting time (for example, in some cases, it may be more concerned with reducing the number of calls to a specific smart contract to reduce costs), the system will instead count the number of tasks for each smart contract and its corresponding tasks. In this step, the system will identify the smart contract with the largest number of tasks as the target smart contract. This means that the smart contract is the busiest in the current transaction pool and may result in higher transaction fees or processing delays due to frequent calls. Therefore, the system merges multiple transaction tasks corresponding to the target smart contract into an aggregated transaction task to reduce the number of calls to the blockchain network and optimize resource usage.
[0048] (5) Merge execution and subsequent processing: Regardless of the merge logic used, once the aggregated transaction tasks are determined, the system will merge these tasks into a single transaction request and submit it to the blockchain network for execution. When the merged transaction tasks are executed, the smart contract function of the blockchain will be used to ensure the consistency and correctness of all related transactions. After the execution is completed, the system will also update the transaction pool status, record the completed transaction tasks, and prepare to process new transaction requests.
[0049] S306 sends the merged transaction to the blockchain node; S307 blockchain node accepts the transaction; S308 The blockchain node sends the transaction credentials of the merged transaction to the aggregation system; S309 The aggregation system records the transaction voucher of the merged transaction and associates it with the generated aggregated transaction voucher; In one embodiment of the present invention, multiple transaction vouchers are combined into one voucher data and the number of transaction vouchers contained in the voucher data is recorded; the voucher data is saved to a storage node; the MD5 value of the voucher data is calculated; the number of transaction vouchers is added to the end of the MD5 value to obtain an aggregated transaction voucher.
[0050] The S3010 blockchain consensus is completed, and blocks are generated to record aggregated transactions.
[0051] S4. The query process includes: Receive a query task, extract target data from the query task; determine whether the target data is in the format of a transaction voucher: if so, determine that the query task is an ordinary query task, send the ordinary query task to the blockchain node, and directly execute the query task through the blockchain node; if not, extract the target MD5 value and the target number of transaction vouchers from the target data in the format of the aggregated transaction voucher, query the existing node for voucher data that completely matches the target MD5 value and the target number of transaction vouchers, disassemble the voucher data into multiple transaction vouchers, and send the multiple transaction vouchers to the blockchain node to execute the query task.
[0052] The following is an exemplary query process: (1) The system receives a query task, which contains the target data to be queried.
[0053] (2) Extract target data: Extract target data from the query task.
[0054] (3) Determine the data format: The system determines whether the target data conforms to the format of a single transaction voucher. This usually involves parsing and format verification of the data.
[0055] (4) Ordinary query task: If the target data conforms to the format of the transaction voucher, the system determines that this is an ordinary query task. At this time, the system will send the query task directly to the blockchain node, which will execute the query operation and return the result.
[0056] (5) Aggregate query task: If the target data does not conform to the format of the transaction voucher, but conforms to the format of the aggregated transaction voucher (i.e., it contains the MD5 value and the number of transaction vouchers), the system will continue to execute the aggregate query process. Extract MD5 value and number of transaction vouchers: Extract the MD5 value and the number of transaction vouchers from the target data. Query the evidence node: Use the extracted MD5 value and the number of transaction vouchers as query conditions to find the voucher data that completely matches it in the evidence node. Dismantle voucher data: If matching voucher data is found, the system will dismantle this aggregated voucher data into multiple independent transaction vouchers. Send query task: Send the dismantled multiple transaction vouchers to the blockchain node, which will execute the query operation and return the result.
[0057] S401, the query process of the transaction task that can be aggregated is as follows Figure 4 As shown, including: (1) The user sends the transaction credentials of the aggregated transaction to the aggregation system; (2) The aggregation system determines that the transaction voucher is an aggregated transaction and finds the associated actual transaction voucher; (3) The aggregation system sends the actual transaction credentials to the blockchain to query the transaction results; (4) The blockchain node returns the transaction result; (5) The aggregation system returns the actual transaction credentials and transaction results to the user.
[0058] S402: If the transaction result is queried for a non-aggregatable smart contract transaction credential, the aggregation system directly transmits it to the blockchain node and returns the result directly to the user.
[0059] In some embodiments, the blockchain transaction aggregation system may include multiple functional modules composed of computer program segments. The computer programs of each program segment in the blockchain transaction aggregation system may be stored in the memory of a computer device and executed by at least one processor to perform (see Figure 1 Description) The function of transaction aggregation of blockchain.
[0060] In this embodiment, the blockchain transaction aggregation system can be divided into multiple functional modules according to the functions it performs, such as Figure 5As shown. The functional modules of the system 500 may include: a transaction identification module 510, a transaction cache module 520, a transaction aggregation module 530, a voucher processing module 540 and a voucher storage module 550. The module referred to in the present invention refers to a series of computer program segments that can be executed by at least one processor and can complete fixed functions, which are stored in a memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.
[0061] A transaction identification module, used for receiving a transaction task and confirming whether the transaction task is an aggregatable transaction task based on a pre-configured transaction classification rule; The transaction cache module is used to cache the aggregatable transaction tasks into a pre-built transaction pool; A transaction aggregation module, used to merge multiple transaction tasks in the transaction pool into an aggregated transaction task, and send the aggregated transaction task to a blockchain node so that the blockchain node executes the aggregated transaction task; A voucher processing module, used to obtain multiple transaction vouchers returned by the blockchain node, and generate an aggregated transaction voucher based on the multiple transaction vouchers; The certificate saving module is used to save the aggregate transaction certificate to the evidence storage node.
[0062] Optionally, as an embodiment of the present invention, the transaction identification module includes: A rule configuration unit, used to pre-configure a transaction classification rule, wherein the transaction classification rule defines aggregatable transaction categories, and smart contract information and user role categories corresponding to the aggregatable transaction categories, wherein the aggregatable transaction categories include voucher transactions and bookkeeping transactions, and the smart contract information corresponding to the aggregatable transaction categories includes a smart contract name and address; An information extraction unit, used to extract the smart contract name and address, and transaction data with a digital signature from the transaction task; A signature parsing unit, used to obtain user information by parsing the digital signature, and obtain a user role category based on the user information; A rule matching unit, used to match the smart contract name and address obtained from the transaction task, and the user role category with the transaction classification rule; A first determination unit, configured to determine that the transaction task is an aggregatable transaction task if the matching is successful; The second determination unit is configured to determine that the transaction task is a common transaction task if the matching fails.
[0063] Figure 6 This is a schematic diagram of the structure of a terminal 600 provided in an embodiment of the present invention. The terminal 600 can be used to execute the transaction aggregation method of the blockchain provided in an embodiment of the present invention.
[0064] The terminal 600 may include: a processor 610, a memory 620 and a communication unit 630. These components communicate via one or more buses. Those skilled in the art will appreciate that the server structure shown in the figure does not limit the present invention, and it may be a bus structure or a star structure, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0065] The memory 620 can be used to store the execution instructions of the processor 610. The memory 620 can be implemented by any type of volatile or non-volatile storage terminal or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. When the execution instructions in the memory 620 are executed by the processor 610, the terminal 600 can execute some or all of the steps in the following method embodiments.
[0066] The processor 610 is the control center of the storage terminal, and uses various interfaces and lines to connect various parts of the entire electronic terminal. It runs or executes software programs and / or modules stored in the memory 620, and calls data stored in the memory to perform various functions of the electronic terminal and / or process data. The processor can be composed of an integrated circuit (IC), for example, it can be composed of a single packaged IC, or it can be composed of multiple packaged ICs with the same or different functions. For example, the processor 610 can only include a central processing unit (CPU). In the embodiment of the present invention, the CPU can be a single computing core or multiple computing cores.
[0067] The communication unit 630 is used to establish a communication channel so that the storage terminal can communicate with other terminals, receive user data sent by other terminals or send user data to other terminals.
[0068] The present invention also provides a computer storage medium, wherein the computer storage medium may store a program, and when the program is executed, the program may include some or all of the steps in each embodiment provided by the present invention. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM).
[0069] Therefore, the present invention reduces the burden of the blockchain and improves the blockchain TPS in disguise by aggregating multiple transaction contents of the smart contract into one transaction according to preset logic without intrusion; at the same time, since multiple transactions are aggregated into one transaction, the number of operations is reduced, the amount of gas consumed is reduced, and the cost is reduced for the contract operator. The technical effects that can be achieved by this embodiment can be found in the description above and will not be repeated here.
[0070] Those skilled in the art can clearly understand that the technology in the embodiments of the present invention can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution in the embodiments of the present invention, in essence or in other words, the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, and other media that can store program codes, including several instructions for enabling a computer terminal (which can be a personal computer, a server, or a second terminal, a network terminal, etc.) to execute all or part of the steps of the methods described in each embodiment of the present invention.
[0071] In this specification, the same or similar parts between the various embodiments can be referred to each other. In particular, for the terminal embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description in the method embodiment.
[0072] In the several embodiments provided by the present invention, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of systems or modules, which can be electrical, mechanical or other forms.
[0073] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0074] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.
[0075] Although the present invention has been described in detail with reference to the accompanying drawings and in combination with the preferred embodiments, the present invention is not limited thereto. Without departing from the spirit and essence of the present invention, a person of ordinary skill in the art may make various equivalent modifications or substitutions to the embodiments of the present invention, and these modifications or substitutions shall be within the scope of the present invention. Any person of ordinary skill in the art may easily think of changes or substitutions within the technical scope disclosed by the present invention, and these shall be within the scope of protection of the present invention.
Claims
1. A transaction aggregation method for blockchain, characterized in that: include: Receiving a transaction task, and confirming whether the transaction task is an aggregatable transaction task based on a pre-configured transaction classification rule; Cache aggregatable transaction tasks into a pre-built transaction pool; Merging multiple transaction tasks in the transaction pool into an aggregated transaction task, and sending the aggregated transaction task to a blockchain node so that the blockchain node executes the aggregated transaction task; Obtain multiple transaction vouchers returned by the blockchain node, and generate an aggregated transaction voucher based on the multiple transaction vouchers; The aggregated transaction voucher is saved to the evidence storage node.
2. The method according to claim 1, characterized in that Receiving a transaction task, and confirming whether the transaction task is an aggregatable transaction task based on a pre-configured transaction classification rule, including: Pre-configure transaction classification rules, wherein the transaction classification rules define aggregable transaction categories, and smart contract information and user role categories corresponding to the aggregable transaction categories, wherein the aggregable transaction categories include voucher transactions and bookkeeping transactions, and the smart contract information corresponding to the aggregable transaction categories includes the smart contract name and address; Extracting the smart contract name and address, as well as the transaction data with digital signature from the transaction task; Obtaining user information by parsing the digital signature, and obtaining the user role category based on the user information; Match the smart contract name and address obtained from the transaction task, as well as the user role category with the transaction classification rules; If the match is successful, the transaction task is determined to be an aggregatable transaction task; If the matching fails, the transaction task is determined to be a common transaction task.
3. The method according to claim 1, characterized in that After caching the aggregatable transaction tasks into a pre-built transaction pool, the method further includes: Monitor the number of transaction tasks in the transaction pool and the execution waiting time, where the execution waiting time is the time from the current moment to the last execution of the transaction task; If the number of the transaction tasks reaches a set task threshold or the execution waiting time reaches a set time threshold, the combined execution of the transaction tasks in the transaction pool is triggered.
4. The method according to claim 1, characterized in that Merging multiple transaction tasks in the transaction pool into an aggregated transaction task, and sending the aggregated transaction task to a blockchain node so that the blockchain node executes the aggregated transaction task, including: Get the waiting time of each transaction task in the transaction pool and filter out the longest waiting time; Determine whether the longest waiting time exceeds a preset waiting threshold: If yes, the transaction task to which the longest waiting time belongs is taken as the core transaction task, and the associated transaction tasks with the same smart contract as the core transaction task are selected from the transaction pool, and the core transaction task and the associated transaction tasks are merged into an aggregated transaction task; If not, the number of smart contracts and tasks corresponding to each smart contract is counted, and the smart contract with the largest number of tasks is used as the target smart contract, and multiple transaction tasks corresponding to the target smart contract are merged into one aggregated transaction task.
5. The method according to claim 1, characterized in that Obtain multiple transaction vouchers returned by the blockchain node, and generate an aggregated transaction voucher based on the multiple transaction vouchers, including: Combining multiple transaction vouchers into one voucher data and recording the number of transaction vouchers included in the voucher data; Saving the credential data to a storage node; Calculate the MD5 value of the credential data; The transaction voucher quantity is added to the end of the MD5 value to obtain an aggregated transaction voucher.
6. The method according to claim 5, characterized in that The method further comprises: receiving a query task, and extracting target data from the query task; Determine whether the implementation target data conforms to the format of the transaction voucher: If so, the query task is determined to be a common query task, and the common query task is sent to the blockchain node, and the query task is directly executed by the blockchain node; If not, extract the target MD5 value and the target number of transaction vouchers from the target data in the format of the aggregated transaction voucher, query the existing node for voucher data that completely matches the target MD5 value and the target number of transaction vouchers, and disassemble the voucher data into multiple transaction vouchers, and send the multiple transaction vouchers to the blockchain node to execute the query task.
7. A blockchain transaction aggregation system, characterized in that: include: A transaction identification module, used for receiving a transaction task and confirming whether the transaction task is an aggregatable transaction task based on a pre-configured transaction classification rule; The transaction cache module is used to cache the aggregatable transaction tasks into a pre-built transaction pool; A transaction aggregation module, used to merge multiple transaction tasks in the transaction pool into an aggregated transaction task, and send the aggregated transaction task to a blockchain node so that the blockchain node executes the aggregated transaction task; A voucher processing module, used to obtain multiple transaction vouchers returned by the blockchain node, and generate an aggregated transaction voucher based on the multiple transaction vouchers; The certificate saving module is used to save the aggregate transaction certificate to the evidence storage node.
8. The system according to claim 7, characterized in that The transaction identification module includes: A rule configuration unit, used to pre-configure a transaction classification rule, wherein the transaction classification rule defines aggregatable transaction categories, and smart contract information and user role categories corresponding to the aggregatable transaction categories, wherein the aggregatable transaction categories include voucher transactions and bookkeeping transactions, and the smart contract information corresponding to the aggregatable transaction categories includes a smart contract name and address; An information extraction unit, used to extract the smart contract name and address, and transaction data with a digital signature from the transaction task; A signature parsing unit, used to obtain user information by parsing the digital signature, and obtain a user role category based on the user information; A rule matching unit, used to match the smart contract name and address obtained from the transaction task, and the user role category with the transaction classification rule; A first determination unit, configured to determine that the transaction task is an aggregatable transaction task if the matching is successful; The second determination unit is configured to determine that the transaction task is a common transaction task if the matching fails.
9. A terminal, characterized in that: include: Storage, used to store the transaction aggregation program of the blockchain; A processor, configured to implement the steps of the blockchain transaction aggregation method as described in any one of claims 1 to 6 when executing the blockchain transaction aggregation program.
10. A computer-readable storage medium storing a computer program, characterized in that: The readable storage medium stores a transaction aggregation program of the blockchain, and when the transaction aggregation program of the blockchain is executed by the processor, the steps of the transaction aggregation method of the blockchain as described in any one of claims 1 to 6 are implemented.