Blockchain extension method, apparatus, computing device, and medium
By establishing a cross-chain bridge in the consortium blockchain, the off-chain part executes and verifies transaction requests and then synchronizes them to the on-chain part, solving the problem of seamless integration of applications in the on-chain and off-chain interaction mode and significantly improving transaction processing performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HANGZHOU QULIAN TECHNOLOGY CO LTD
- Filing Date
- 2022-05-11
- Publication Date
- 2026-04-21
AI Technical Summary
The processing speed of consortium blockchains based on complex smart contracts cannot meet the massive request demands of public service infrastructure, and seamless integration of applications under on-chain and off-chain interaction modes is difficult to achieve.
A cross-chain bridge is established between the on-chain and off-chain parts, including the blockchain's program interface and smart contract constraints. The off-chain part executes transaction requests and verifies them through smart contract constraints. Once verified, the transaction is synchronized to the on-chain part.
It enables seamless migration between on-chain and off-chain interaction modes, improves transaction processing performance by 4-5 orders of magnitude, and meets the needs of public service infrastructure.
Smart Images

Figure CN115082231B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of blockchain technology, and in particular relates to a method, apparatus, computing device and medium for extending blockchain. Background Technology
[0002] Consortium blockchains can be applied to the public service sector. Public service infrastructure typically faces massive request pressure, while the processing speed of consortium blockchains, based on complex smart contracts, is generally only 100-1000 tps, far from meeting the requirements of public service infrastructure.
[0003] To handle massive requests, consortium blockchains typically use an on-chain contract to store hashes and an off-chain storage and business logic processing architecture to achieve on-chain-off-chain interaction. This on-chain-off-chain interaction model can expand the service performance that the blockchain can support by several orders of magnitude and meet business needs.
[0004] However, when using the on-chain and off-chain interaction model for blockchain, applications that use this blockchain for transactions need to be adjusted accordingly, and seamless integration cannot be achieved for the applications. Summary of the Invention
[0005] In view of this, embodiments of this application provide a blockchain extension method, apparatus, computing device, and medium to achieve seamless migration of applications in an on-chain and off-chain interaction mode.
[0006] A first aspect of this application provides a method for extending a blockchain, applied to a blockchain comprising an on-chain portion and an off-chain portion, the method comprising:
[0007] A cross-chain bridge is established between the on-chain portion and the off-chain portion, the cross-chain bridge including the blockchain's program interface and smart contract constraints;
[0008] When a transaction request is received, the off-chain portion is used to execute the transaction request and obtain a transaction record;
[0009] The transaction records are verified using the constraints of the smart contract.
[0010] If the transaction record passes verification, the program interface is used to synchronize the transaction record to the on-chain portion.
[0011] A second aspect of this application provides a blockchain extension device applied to a blockchain, the blockchain including an on-chain portion and an off-chain portion, the device comprising:
[0012] A module is established to establish a cross-chain bridge between the on-chain portion and the off-chain portion, the cross-chain bridge including the blockchain's program interface and smart contract constraints;
[0013] The off-chain execution module is used to execute the transaction request using the off-chain part when a transaction request is received, and to obtain the transaction record;
[0014] A cross-chain bridge verification module is used to verify the transaction records using the smart contract constraints;
[0015] The on-chain synchronization module is used to synchronize the transaction record to the on-chain portion using the program interface if the transaction record passes verification.
[0016] A third aspect of this application provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method described in the first aspect above.
[0017] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in the first aspect above.
[0018] A fifth aspect of this application provides a computer program product that, when run on a computer device, causes the computer device to perform the method described in the first aspect.
[0019] Compared with the prior art, the embodiments of this application have the following advantages:
[0020] In this embodiment, the blockchain can include an on-chain portion and an off-chain portion, and a cross-chain bridge can be established between the on-chain and off-chain portions. When a transaction request is received from an application, the off-chain portion of the blockchain can execute the transaction request to obtain a transaction record; then, the cross-chain bridge verifies the transaction record; after successful verification, the cross-chain bridge can synchronize the transaction record to the on-chain portion. The cross-chain bridge can include the blockchain's program interface and smart contract constraints. Smart contract constraints can be used to verify the transaction record obtained from off-chain execution and quickly synchronize the verified transaction record to the blockchain. In the on-chain / off-chain interaction mode, constraints can also be imposed on off-chain computations. Furthermore, during the process of converting the blockchain from its original mode to an on-chain / off-chain interaction mode, applications using the blockchain do not need to make corresponding adjustments to the blockchain; instead, they can be seamlessly migrated directly. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 This is a flowchart illustrating the steps of a blockchain extension method provided in an embodiment of this application;
[0023] Figure 2 This is a schematic diagram of an extended blockchain provided in an embodiment of this application;
[0024] Figure 3 This is a schematic diagram of a blockchain extension device provided in an embodiment of this application;
[0025] Figure 4 This is a schematic diagram of a computer device provided in an embodiment of this application. Detailed Implementation
[0026] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0027] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0028] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0029] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0030] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0031] The technical solution of this application will be described below through specific embodiments.
[0032] Reference Figure 1 This illustration shows a flowchart of a blockchain extension method provided in an embodiment of this application, which may specifically include the following steps:
[0033] S101, establish a cross-chain bridge between the on-chain portion and the off-chain portion, the cross-chain bridge including the blockchain's program interface and smart contract constraints.
[0034] The execution entity in this embodiment is a blockchain, which can include an on-chain portion and an off-chain portion. The on-chain portion can include smart contract constraints, which may include multiple smart contracts. Smart contracts are protocols for handling transactions for various nodes on the blockchain, and each node processes transactions according to the smart contracts. The off-chain portion of the blockchain provides off-chain services and can be used to process transaction requests.
[0035] The on-chain and off-chain components employ different architectures and systems due to their different functionalities. Previously, applications communicating with the blockchain used the on-chain communication language. However, in the on-chain / off-chain interaction model, the business transaction requests sent by the application are executed by the off-chain component. Therefore, if the blockchain directly interacts with off-chain services, its original communication language needs to be changed. This creates a problem of seamless application migration for off-chain blockchain expansion.
[0036] In this embodiment, a cross-chain bridge is established between the on-chain and off-chain components. The cross-chain bridge can include the blockchain's program interface and smart contract constraints. The cross-chain bridge exposes the same interfaces and smart contract constraints to the business program as the original blockchain, and performs local computation of off-chain transactions, off-chain ledger management, and transaction verification mechanisms implemented using the blockchain. The cross-chain bridge consists of off-chain services and on-chain verification and consistency contracts.
[0037] Because off-chain services differ from blockchain node solutions and have different execution environments than on-chain smart contracts, the off-chain portion can use a smart contract interpreter to convert syntax. Off-chain services support all smart contract constraints supported by the blockchain. Application developers can develop smart contracts according to blockchain specifications and then submit operations such as contract deployment, invocation, and upgrades to the off-chain service. The off-chain service inputs this request into the smart contract interpreter, which interprets the input into intermediate code executable by the off-chain virtual machine within the off-chain service. During the synchronization time, the service waits for the smart contract interpreter's return, which is categorized according to the request, including deployment results, invocation results, and upgrade results. The smart contract interpreter then interprets the returned result into the smart contract's native language and encapsulates it into an interface return message under blockchain constraints before sending it to the application caller.
[0038] S102, when a transaction request is received, the off-chain part is used to execute the transaction request to obtain a transaction record.
[0039] Specifically, the off-chain component can include a smart contract interpreter and an off-chain virtual machine. The smart contract interpreter can perform mutual interpretation between the smart contract language and the virtual machine language.
[0040] When the blockchain receives a transaction request from another application, it can execute the request off-chain. A smart contract interpreter can be used to interpret the transaction request, obtaining virtual machine execution code; then, an off-chain virtual machine executes the virtual machine code, obtaining the execution result; finally, the smart contract interpreter interprets the execution result again, obtaining the transaction record. In one possible implementation, the off-chain portion can form multiple off-chain nodes based on different transaction processing needs, each of which can include a virtual machine. Based on different transaction requests, different target off-chain nodes can be determined to execute the transaction request; then, the off-chain virtual machine in the target off-chain node is called to execute the virtual machine code, obtaining the execution result.
[0041] S103, The transaction record is verified using the smart contract constraints.
[0042] Specifically, cross-chain transactions can include smart contract constraints, which can be used to directly verify the transaction record.
[0043] In one possible implementation, transaction records can be broadcast to all nodes in the blockchain. Then, within a preset time window, if a challenge to the transaction record is received from any node, the transaction record is verified using smart contract constraints in response to the challenge. During verification, the target smart contract can be determined from the smart contract constraints based on the transaction information carried in the transaction record; then, the target smart contract is invoked to verify the transaction record.
[0044] In one possible implementation, the blockchain can include multiple off-chain nodes. Since the off-chain portion lacks a consensus mechanism, the results calculated by the various off-chain nodes do not reach a consensus. When using a cross-chain bridge to verify transaction records, off-chain nodes can submit the transaction record to the bridge. Once submitted, the transaction record becomes visible to all off-chain nodes. Any off-chain node can challenge the transaction record within a preset time window. If no challenge is received within the preset time window, the transaction record is directly added to the blockchain. If a challenge is received within the preset time window, it needs to be verified through a verification contract.
[0045] In one possible implementation, the on-chain verification contract is primarily used to manage and verify the correctness of off-chain transaction execution. Generally, after an off-chain transaction is executed, the execution result can be submitted to the verification contract via a cross-chain bridge. The verification contract verifies the transaction signature and the validity of the result, thus completing the verification of the off-chain batch transactions. When an off-chain transaction execution error occurs, the verification contract uses a binary search approach to find the specific conflict point in the transaction execution and submits that section of the contract instruction to the on-chain smart contract virtual machine for execution, thereby verifying the correctness of the execution of the disputed instruction.
[0046] In one possible implementation, after performing an off-chain computation, an off-chain node can submit an assertion to the on-chain smart contract of the blockchain via a cross-chain bridge. This assertion has a corresponding virtual machine world state hash and virtual machine execution operation. The virtual machine world state hash can be used to represent the execution stage of a virtual machine. Each off-chain computation that modifies the stored data will change the virtual machine world state hash. The virtual machine execution operation can include the local contract program executed by the virtual machine, the local contract program method name, the method parameters, etc.
[0047] The aforementioned assertion can correspond to an off-chain computation by an off-chain node. For example, during a chess game, the game itself can be considered an off-chain computation. After obtaining the result, the off-chain node can submit this game as an assertion to the on-chain smart contract. The on-chain smart contract then needs to verify its correctness, thereby constraining the off-chain computation on-chain.
[0048] Once an assertion is submitted to the cross-chain bridge, it becomes visible to all nodes on the blockchain, and therefore, all off-chain nodes can also see it. If an off-chain node believes the assertion is incorrect, it can challenge it. The on-chain smart contract can open a preset time window during which off-chain nodes can challenge the assertion. Challenging an assertion by an off-chain node signifies that it is questioning the assertion. When an assertion is challenged, the cross-chain bridge can invoke the on-chain verification contract to determine the dispute between the off-chain nodes and the other nodes regarding the assertion.
[0049] S104, If the transaction record passes verification, the transaction record is synchronized to the on-chain portion using the program interface.
[0050] If the transaction record is verified, it can be synchronized to the blockchain for on-chain storage.
[0051] In one possible implementation, when multiple transaction requests conflict off-chain, the conflicting execution portions of the requests can be identified. These conflicting portions are then submitted to the on-chain system via a cross-chain bridge, where they are then evaluated. For example, different off-chain nodes might simultaneously need to write to the same data; the order in which they execute these operations could lead to different consequences, resulting in a conflict. This data, along with the two off-chain nodes, can be submitted to the on-chain system and constrained by an on-chain contract.
[0052] In one possible implementation, due to the high speed of off-chain computation, transaction requests are typically processed in batches off-chain. Multiple received transaction requests can be packaged into a transaction request packet; then, the off-chain portion executes each transaction request in the packet in batches, resulting in batch transaction records. These batch transaction records are then submitted to a cross-chain bridge for verification. If the batch transaction records pass verification, the cross-chain bridge synchronizes them to the on-chain portion. Due to the batch transaction packaging mechanism, there may be conflicts in the execution instructions of a single transaction or conflicts in the execution instructions of multiple transactions. These conflicts can be resolved by submitting them to the on-chain portion via the cross-chain bridge.
[0053] The off-chain portion enables batch transaction management. Batch transaction management aggregates and packages the transaction proposals submitted by the application, executes them locally in batches, and returns the execution results in batches. The timing and scheme of batch execution are determined by the combination of execution interval and the number of backlogged transactions. Since the off-chain service does not have a blockchain consensus mechanism, the batch transaction management scheme can increase transaction times per second by thousands or tens of thousands of times.
[0054] In this embodiment, by providing an off-chain virtual machine for off-chain computation, the off-chain computation is subject to verifiable constraints by on-chain contracts, which can effectively identify malicious behavior. By executing batches of off-chain transactions and performing a small number of on-chain verification processes, the transaction processing performance can be improved by 4-5 orders of magnitude while ensuring that off-chain computation inherits the security of on-chain computation.
[0055] It should be noted that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0056] Figure 2 This is a schematic diagram of an extended blockchain provided in an embodiment of this application. For example... Figure 2 As shown, the blockchain includes Blockchain B and off-chain services. Blockchain B in the diagram represents the on-chain portion. Off-chain services can include smart contract interpretation, off-chain virtual machines, consistency management, and batch transaction management. A cross-chain bridge is built between Blockchain B and the off-chain services. For business smart contracts, their business initiation is directed to the entire blockchain. When a transaction request is received, the off-chain service executes it, and then the cross-chain bridge synchronizes it to Blockchain B. Business smart contracts do not need to consider the blockchain structure and can be seamlessly migrated.
[0057] Off-chain service consistency management and on-chain consistency contracts together constitute a cross-chain bridge to guarantee data consistency between on-chain and off-chain transactions. This ensures that after a batch of off-chain transactions are executed, the off-chain transaction records stored on-chain are updated. When conflicts arise in off-chain transaction execution, the conflicting portion is submitted to blockchain B for on-chain transaction verification to determine the correctness of the transaction execution. If a portion of the off-chain transaction execution disputes are determined to be invalid on-chain, the consistency solution needs to correct the correctness of the off-chain data execution by internally writing back the off-chain contract.
[0058] In this embodiment, off-chain nodes are responsible for processing business transactions. Off-chain nodes execute transaction requests according to the smart contract model and batch package a batch of transactions to submit to the cross-chain bridge. The cross-chain bridge consists of an on-chain smart contract and a program. After receiving this batch of transactions, the cross-chain bridge verifies the correctness of the execution of this batch of transactions and waits for assertions from other off-chain nodes to ensure consistency. After the public period, the cross-chain bridge packages this batch of off-chain transactions into a large on-chain transaction, submits it for on-chain execution, and finally places it in a block.
[0059] Reference Figure 3This diagram illustrates a blockchain extension device provided in an embodiment of this application. The device can be applied to a blockchain, which includes an on-chain portion and an off-chain portion. Specifically, it may include an establishment module 31, an off-chain execution module 32, a cross-chain bridge verification module 33, and an on-chain synchronization module 34, wherein:
[0060] Establishment module 31 is used to establish a cross-chain bridge between the on-chain part and the off-chain part, the cross-chain bridge including the program interface and smart contract constraints of the blockchain;
[0061] The off-chain execution module 32 is used to execute the transaction request using the off-chain part when a transaction request is received, and obtain the transaction record;
[0062] The cross-chain bridge verification module 33 is used to verify the transaction record using the smart contract constraints;
[0063] The on-chain synchronization module 34 is used to synchronize the transaction record to the on-chain portion using the program interface if the transaction record passes verification.
[0064] In one possible implementation, the off-chain portion includes a smart contract interpreter and an off-chain virtual machine, wherein the off-chain execution module 32 includes:
[0065] The first interpretation submodule is used to interpret the transaction request using the smart contract interpreter to obtain virtual machine executable code;
[0066] The virtual machine execution submodule is used to execute the virtual machine execution code using the off-chain virtual machine to obtain the virtual machine execution result;
[0067] The first interpretation submodule is used to interpret the execution result of the virtual machine using the smart contract interpreter to obtain the transaction record.
[0068] In one possible implementation, the off-chain portion includes multiple off-chain nodes, each of which handles transaction requests corresponding to different businesses. Each off-chain node includes an off-chain virtual machine, and the virtual machine execution submodule includes:
[0069] A determining unit is used to determine the target off-chain node for processing the transaction request;
[0070] The invocation unit is used to invoke the off-chain virtual machine in the target off-chain node to execute the virtual machine execution code and obtain the virtual machine execution result.
[0071] In one possible implementation, the above-mentioned device further includes:
[0072] A broadcast module is used to broadcast the transaction records to each node of the blockchain;
[0073] The receiving module is configured to, within a preset time window, if it receives a challenge to the transaction record submitted by any node, verify the transaction record using the smart contract constraints in response to the challenge.
[0074] In one possible implementation, the cross-chain bridge verification module 33 includes:
[0075] The determination module is used to determine the target smart contract from the smart contract constraints based on the transaction information carried in the transaction record;
[0076] The calling module is used to invoke the target smart contract to verify the transaction record.
[0077] In one possible implementation, the above-mentioned device further includes:
[0078] A conflict determination module is used to determine the conflicting execution parts of multiple transaction requests when multiple transaction requests conflict in the off-chain portion.
[0079] A submission module is used to submit the conflict execution part to the on-chain part through the cross-chain bridge;
[0080] The judgment module is used to judge the conflict execution part using the chain part.
[0081] In one possible implementation, the above-mentioned device further includes:
[0082] The packaging module is used to package multiple received transaction requests into a transaction request package;
[0083] The batch execution module is used to batch execute each transaction request in the transaction request packet using the off-chain part to obtain batch transaction records;
[0084] A batch verification module is used to submit the batch transaction records to the cross-chain bridge for verification;
[0085] A batch synchronization module is used to synchronize the batch transaction records to the on-chain portion using the cross-chain bridge if the batch transaction records pass verification.
[0086] As the apparatus embodiments are basically similar to the method embodiments, they are described in a relatively simple manner. For relevant details, please refer to the description in the method embodiment section.
[0087] Figure 4 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Figure 4As shown, the computer device 4 of this embodiment includes: at least one processor 40 ( Figure 4 (Only one is shown) a processor, a memory 41, and a computer program 42 stored in the memory 41 and executable on the at least one processor 40, which, when executing the computer program 42, implements the steps in any of the above method embodiments.
[0088] The computer device 4 can be a desktop computer, laptop, handheld computer, or cloud server, etc. This computer device may include, but is not limited to, a processor 40 and a memory 41. Those skilled in the art will understand that... Figure 4 The computer device 4 is merely an example and does not constitute a limitation on the computer device 4. It may include more or fewer components than shown, or combine certain components, or different components, such as input / output devices, network access devices, etc.
[0089] The processor 40 may be a Central Processing Unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0090] In some embodiments, the memory 41 may be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. In other embodiments, the memory 41 may be an external storage device of the computer device 4, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., equipped on the computer device 4. Furthermore, the memory 41 may include both internal and external storage units of the computer device 4. The memory 41 is used to store the operating system, applications, bootloader, data, and other programs, such as the program code of the computer program. The memory 41 can also be used to temporarily store data that has been output or will be output.
[0091] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps described in the various method embodiments above.
[0092] This application provides a computer program product that, when run on a computer device, enables the computer device to perform the steps described in the above-described method embodiments.
[0093] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include at least: any entity or device capable of carrying computer program code to a computer device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.
[0094] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0095] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0096] In the embodiments provided in this application, it should be understood that the disclosed apparatus / computer devices and methods can be implemented in other ways. For example, the apparatus / computer device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings or direct couplings or communication connections may be through some interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0097] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0098] The embodiments described above are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method for extending a blockchain, characterized in that, Applied to a blockchain, which includes an on-chain portion and an off-chain portion, the method includes: A cross-chain bridge is established between the on-chain portion and the off-chain portion. The cross-chain bridge includes the program interface and smart contract constraints of the blockchain. The cross-chain bridge is used to expose the same interface and smart contract constraints as the original blockchain to the business program, and to complete the local computation of off-chain transactions, off-chain ledger management, and transaction verification mechanism implemented with the help of the blockchain. When a transaction request is received, the off-chain portion is used to execute the transaction request and obtain a transaction record; The transaction records are verified using the constraints of the smart contract. If the transaction record passes verification, the program interface is used to synchronize the transaction record to the on-chain portion.
2. The method as described in claim 1, characterized in that, The off-chain component includes a smart contract interpreter and an off-chain virtual machine. The execution of the transaction request using the off-chain component to obtain transaction records includes: The smart contract interpreter is used to interpret the transaction request to obtain virtual machine executable code; The virtual machine execution code is executed using the off-chain virtual machine to obtain the virtual machine execution result; The smart contract interpreter is used to interpret the execution result of the virtual machine to obtain the transaction record.
3. The method as described in claim 2, wherein the off-chain portion includes multiple off-chain nodes, each off-chain node is used to process transaction requests corresponding to different businesses, each off-chain node includes the off-chain virtual machine, and the step of using the off-chain virtual machine to execute the virtual machine execution code to obtain the virtual machine execution result includes: Identify the target off-chain node to process the transaction request; The off-chain virtual machine in the target off-chain node is invoked to execute the virtual machine execution code, and the execution result of the virtual machine is obtained.
4. The method according to any one of claims 1-3, characterized in that, Before verifying the transaction record using the smart contract constraints, the method further includes: The transaction records are broadcast to each node of the blockchain; If a challenge to the transaction record is received from any node within a preset time window, the transaction record will be verified using the smart contract constraints in response to the challenge.
5. The method as described in claim 4, characterized in that, The verification of the transaction record using the smart contract constraints includes: Based on the transaction information carried in the transaction records, the target smart contract is determined from the smart contract constraints; The target smart contract is invoked to verify the transaction record.
6. The method as described in claim 1, characterized in that, The method further includes: When multiple transaction requests conflict in the off-chain portion, the conflicting execution portions of the multiple transaction requests are determined; The conflict execution portion is submitted to the on-chain portion via the cross-chain bridge; The conflict execution part is judged using the chain portion.
7. The method as described in claim 1, characterized in that, The method further includes: Package the received multiple transaction requests into a transaction request package; The off-chain portion is used to batch execute each transaction request in the transaction request packet to obtain batch transaction records; The batch transaction records are submitted to the cross-chain bridge for verification. If the batch transaction records pass verification, the cross-chain bridge is used to synchronize the batch transaction records to the on-chain portion.
8. A blockchain extension device, characterized in that, Applied to blockchain, which includes an on-chain portion and an off-chain portion, the device includes: A module is established to establish a cross-chain bridge between the on-chain part and the off-chain part. The cross-chain bridge includes the program interface and smart contract constraints of the blockchain. The cross-chain bridge is used to expose the same interface and smart contract constraints as the original blockchain to the business program, and to complete the local computation of off-chain transactions, off-chain ledger management, and transaction verification mechanism implemented with the help of the blockchain. The off-chain execution module is used to execute the transaction request using the off-chain part when a transaction request is received, and to obtain the transaction record; A cross-chain bridge verification module is used to verify the transaction records using the smart contract constraints; The on-chain synchronization module is used to synchronize the transaction record to the on-chain portion using the program interface if the transaction record passes verification.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1-7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-7.
Citation Information
Patent Citations
Cross-chain contract analysis method of block chain, relay chain and cross-chain system
CN112488679A