A fast execution method for cross-chain smart contracts for Rollups chains
By constructing state channels between Rollups chains and deploying referee contracts on the main chain, the problem of difficult execution of smart contracts between Rollups chains is solved, efficient and safe cross-chain interoperability is achieved, costs are reduced and security is improved.
Patent Information
- Application Number
- CN202410918530.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-10
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2044-07-10
AI Technical Summary
Existing technology makes it difficult to efficiently execute smart contracts between Rollups chains and requires the participation of a trusted third party, resulting in high interoperability costs, low efficiency, and insufficient security.
By building a cross-Rollups chain status channel off-chain, participants execute the contract off-chain and reach consensus through the status channel to ensure consistency and security. When consensus cannot be reached, the referee contract is deployed on the main chain to resolve disputes and achieve mandatory execution.
Without relying on a trusted third party, it can efficiently execute smart contracts across Rollups chains, reduce interoperability costs, and improve interoperability and security between Rollups chains.
Smart Images

Figure CN118473639B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of cross-chain blockchain technology, and in particular to a cross-chain smart contract fast execution method for Rollups chains. Background Art
[0002] Rollups is a second layer (Layer 2) scaling solution designed to improve the throughput and efficiency of the base layer blockchain (main chain). Rollups package multiple transactions into a single data packet by processing and executing transactions off-chain (outside the main chain), and then submit a summary of these transactions or a validity proof back to the main chain. Rollups can significantly reduce the amount of data and processing requirements on the main chain, which not only ensures the security and decentralization of transactions, but also significantly improves the throughput and transaction speed of the network. In addition, in order to realize the migration of assets and data between the main chain and the Rollups chain, a message communication mechanism is built between the main chain and the Rollups chain, which can realize message transmission between the main chain and the Rollups chain.
[0003] Rollups technology is developing rapidly. There are currently many Rollups chains. These Rollups chains often need to interoperate very frequently because there are a lot of shared data and assets between the main chain and the Rollups chain. This makes the assets and data between the Rollups chains have a high degree of overlap, which makes the Rollups chains have stronger interoperability requirements.
[0004] Because Rollups chains cannot obtain each other's status, it is very difficult to execute smart contracts across Rollups chains while ensuring consistency and security. In order to realize user operations between Rollups chains, a simple solution is to transmit messages or assets through the main chain, but this solution is too expensive and often requires a long waiting period (1 week). It is feasible to apply existing cross-chain solutions to Rollups chains, but existing cross-chain solutions are often expensive and require a trusted third party. Hash time lock is a lighter solution, but its disadvantage is that it can only handle asset exchanges, cannot execute smart contracts, and can only process one transaction after the channel is established, which is obviously not applicable to complex scenarios. Summary of the invention
[0005] In order to overcome the shortcomings of the prior art, the present invention provides a cross-chain smart contract fast execution method for Rollups chain, which can efficiently execute cross-Rollups chain smart contracts while ensuring the correctness, consistency and activity of the system.
[0006] In order to achieve the above-mentioned object of the invention, the technical solution of the present invention includes the following contents.
[0007] A cross-chain smart contract fast execution method for Rollups chain, the method comprising:
[0008] For contracts that require cross-chain execution Each participant builds a cross-Rollups chain state channel under the chain and transfers the state that needs to cross the chain and assets locked in the contract middle;
[0009] Each participant is based on the status of the chain Execution of the contract , get the updated status , and use the cross-Rollups chain state channel to perform state consensus; among them, is a natural number;
[0010] Each party has a status After reaching consensus, the status of each participant in the chain will be updated to , and based on the state Continue to execute the contract , until all parties agree to close the cross-Rollups chain state channel;
[0011] Close the cross-Rollups chain state channel and perform settlement based on the latest status.
[0012] Furthermore, for contracts that require cross-chain execution , each participant builds a state channel across the Rollups chain, including:
[0013] All parties jointly sign the state channel across the Rollups chain ;in, Representation state channel The ID set of all Rollups chains involved, It's a contract Address, It is a challenging period;
[0014] ID set of each participating direction The channel management contracts of all specified Rollups chains submit jointly signed state channels .
[0015] Furthermore, each participant is based on the status of Execution of the contract , get the updated status , and use the cross-Rollups chain state channel to perform state consensus, including:
[0016] One party based on the contract Address and status Execution of the contract , get the updated status ;
[0017] Based on the cross-Rollups chain state channel, other participants will and an incremental version identifier; wherein the incremental version identifier includes a status and increment the version number ;
[0018] When the participant collects the updated status of other participants After signing, proceed to status Updates.
[0019] Furthermore, the closing of the cross-Rollups chain state channel and the settlement based on the latest state include:
[0020] When both parties agree to close the channel, each party signs the latest status and the closed channel tag;
[0021] Send the latest status of the co-signature and the closed channel tag to the ID collection Specify the channel management contracts of all Rollups chains so that each channel management contract allocates assets according to the asset balance specified in the latest status.
[0022] Furthermore, the method further comprises:
[0023] The parties involved cannot When consensus is reached, the final state of resolving the dispute is obtained through the arbitration contract deployed on the main chain. ;
[0024] The contract Deployed on the main chain and based on the final state on the main chain Complete the contract the enforcement of
[0025] ID Collection The channel management contracts of all specified Rollups chains are based on enforcing the final state of the output proceed to checkout.
[0026] Furthermore, the final state of resolving the dispute is obtained through the arbitration contract deployed on the main chain. ,include:
[0027] Any party submits status and challenge period to the referee contract deployed on the main chain; where the state The latest status signed by all parties;
[0028] The party sends a dispute resolution start transaction to the ID set All specified Rollups chains;
[0029] Any other party who initiates a transaction based on the dispute resolution during the challenge period Use the latest state signed by all parties Regarding the status Conduct a challenge;
[0030] In the state The version number is higher than the state In the case, based on the status Regarding the status To cover;
[0031] Output the final status of dispute resolution .
[0032] Furthermore, based on the final state on the main chain Complete the contract enforcement, including:
[0033] The final state As a main chain contract The initial state of
[0034] Each party executes the contract on the main chain , and get the final state .
[0035] Furthermore, the ID set The channel management contracts of all specified Rollups chains obtain the final state The process includes:
[0036] contract The final state Send to referee contract;
[0037] The final state of the referee contract Send to ID collection The channel management contract for all specified Rollups chains.
[0038] A computer-readable storage medium having computer program instructions stored thereon, wherein the computer program instructions, when executed by a processor, implement any of the above-mentioned methods for fast execution of cross-chain smart contracts for Rollups chains.
[0039] Compared with the prior art, the present invention can efficiently realize the execution of smart contracts across Rollups chains without the need for a trusted third party, improve the interoperability between Rollups chains, reduce the interoperability cost of Rollups chains, and increase the security and efficiency of interoperability between Rollups chains. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 Flowchart of the cross-chain smart contract fast execution method of the present invention. DETAILED DESCRIPTION
[0041] The present invention is further described in detail below in conjunction with the accompanying drawings. The examples given are only used to explain the present invention but not to limit the scope of the present invention.
[0042] In traditional cross-chain solutions, since chains cannot obtain each other's status and there is no strict global synchronization clock, trusted third-party relay nodes are required to ensure their security. In order to avoid relying on relay nodes, the present invention uses the main chain to Rollups chain message mechanism to implement a cross-Rollups chain state channel that does not require trusted relay nodes, and uses the main chain to ensure the security of cross-chain operations in the worst case. The main chain to Rollups chain message mechanism is a basic message mechanism provided by each Rollups chain, which allows smart contracts on the main chain to send messages to contracts on the Rollups chain. Therefore, the method provided by the present invention can be applied to almost all Rollups chains.
[0043] Specifically, the parties who need to execute smart contracts across Rollups chains first build a cross-Rollups chain state channel, which allows the parties to execute smart contracts across Rollups chains by exchanging signatures on the latest state off-chain. When the parties complete the contract execution, the latest agreed-upon state will be submitted to all Rollups chains in the channel, and each Rollups chain will be updated to the latest state and the channel will be closed. If one party cheats or stops cooperating during the execution process, the other parties can complete the contract execution through the main chain-based dispute resolution procedure and mandatory contract execution procedure, which ensures that each Rollups chain will be updated to a consistent final state.
[0044] The following description will be made by taking the example that the participants include only two parties, A and B. However, it is easy to understand that the participants of the present invention may include more than two parties. Figure 1As shown, the specific technical solution provided by the present invention is as follows:
[0045] Step A: The two parties involved build a state channel on the Rollups chain where the cross-chain smart contract needs to be executed.
[0046] The two parties involved first jointly sign the channel information, and send the signature and channel information to the channel management contract of all Rollups chains in the channel. Then, they verify the signature on the channel management contract on the Rollups chain, open the channel according to the channel information, and lock the status and assets involved.
[0047] In one embodiment, the state channel construction process is performed in the following manner.
[0048] A1. Both parties jointly sign the channel , where the set Contains the IDs of all Rollups chains involved in the channel, It is a contract that needs to be executed across chains Address, It's a contract The initial state of It is the challenge period used during the dispute resolution phase.
[0049] A2. Both parties (A and B) move to the collection The channel management contracts of all specified Rollups chains submit the jointly signed channel , and lock the state and assets that need to cross the chain in the contract.
[0050] Step B: Both parties execute the cross-Rollups chain contract.
[0051] When the two parties execute the contract off-chain by exchanging signatures, the parties save the latest status of the contract locally. The party (assuming it is A) executes the contract based on the status to obtain the new contract status and signs the status, and sends the status and signature to the other party (B); then, if party B approves the status, it signs the status and sends it to party A; finally, when the party collects the signatures of all other parties on the status, it updates the status to the latest status locally.
[0052] In one embodiment, executing a cross-Rollups chain contract includes the following:
[0053] B1. Channel Once established, the parties can execute the contract offline by signing a new state transition , for example, the current state is , both parties jointly agree on the status Signed, the contract status is determined by Migrate to ;
[0054] B2. In order to identify the latest state, an incremental version number is added to each state transition , and both parties need to Sign together;
[0055] B3. The signed state with a higher version number is the latest state of the contract and will always overwrite the signed state with a lower version number.
[0056] Step C: Both parties close the state channel.
[0057] The two parties involved sign a channel closing message for the latest status, and send the signed message to the channel management contract of all Rollups chains. After the signature verification is passed, the channel management contract will settle (unlock status and assets) according to the status given in the channel closing message.
[0058] In one embodiment, closing the status channel includes the following.
[0059] C1. When both parties agree to close the channel, they sign the latest status and a CLOSE tag, i.e. ;
[0060] C2. Both parties will sign The channel management contract is sent to all Rollups chains involved in the channel. The channel management contract verifies the signature. After the management contract verifies the signature, it will be transferred according to the status. Settle and close the channel.
[0061] Step D: Dispute Resolution and Enforcement.
[0062] If one party refuses to cooperate (for example, by not providing a signature), the other party can initiate dispute resolution on the main chain and continue to execute the contract on the main chain. When the final state is determined on the main chain, the main chain will send the final state to all Rollup chains in the channel. When the Rollup chain receives the final state, it will settle according to the final state and close the channel.
[0063] In one embodiment, if one of the participants acts maliciously, the two parties can resolve the dispute on the main chain in the following ways:
[0064] D11. A referee contract is deployed on the main chain. Either party can submit the latest status signed by both parties to the referee contract to start dispute resolution.
[0065] D12. To prevent attacks, before starting dispute resolution, one party needs to send a "Dispute Resolution Start" transaction to all Rollups chains, which will make the ongoing state channel only able to be closed through the arbitration contract of the main chain.
[0066] D13. In order to ensure that the "dispute resolution" can determine the latest status, a challenge period will be started after submitting the dispute resolution on the main chain. During the challenge period, the other party can submit a newer (higher version number) state signed by both parties to overwrite the old state.
[0067] D14. After the challenge period ends, the main chain will receive the state signed by both parties with the highest version number as the latest state.
[0068] In one embodiment, after determining the latest status, the parties can enforce the contract in the following ways:
[0069] D21. Participants who wish to enforce the contract must first Deploy to the main chain, the contract address is cm;
[0070] D22. Contract Accept the final status obtained from dispute resolution (process D) is the initial state of the contract;
[0071] D23. Both parties execute the contract on the main chain , and get the final state ;
[0072] D24. Contract The final state Sent to the referee contract, the referee contract will Sent to the channel management contract of all Rollups chains in the channel;
[0073] D25. The channel management contract receives the status sent by the referee contract Later, according to Settlement is performed and the channel is closed.
[0074] The present invention is further described below by means of a specific example.
[0075] Assuming that user A and user B want to jointly execute contract CT on Rollups chain A and Rollups chain B, user A and user B will sign the information in the following format respectively:
[0076] struct MetaData {
[0077] address[2] owners; / / Addresses of user A and user B
[0078] IERC20[2] tokens; / / Token contract address
[0079] uint64[2] chainIds; / / chainId, so that layer1 contract can trigger the correct layer2 contract
[0080] uint128[2] minValues; / / Minimum incoming msg.value, to ensure that the message can be called correctly
[0081] uint64 challengeTime; / / The time it takes for the user to respond to the challenge on L1
[0082] mapping states; / / Initial state
[0083] }
[0084] User A or User B sends the above signed information to the channel management contract of Rollups chain A and Rollups chain B. The channel management contract locks the data and assets according to the initial state, and calculates the hash of the above information to obtain the channel id: h.
[0085] User A and User B execute contract CT off-chain. For example, User A executes contract CT to obtain a new state ,Will Package it into the following format and sign it before sending it to user B:
[0086] struct StateUpdate {
[0087] bytes32 channelHash, / / channel address
[0088] uint32 version, / / status version number
[0089] mapping states / / New state
[0090] }
[0091] After receiving the signed new status information, User B verifies the status and signature. After verification, he signs and sends the signature to User A.
[0092] User A and User B repeat the above process to update the state execution contract.
[0093] When User A and User B agree to close the channel, they jointly sign the following information:
[0094] struct CloseChannel {
[0095] bytes32 channelHash, / / channel address
[0096] string "CLOSE", / / Close flag
[0097] mapping states / / final state
[0098] }
[0099] The signed message is sent to the channel management contract on Rollups chain A and Rollups chain B. After receiving the message, the channel management contract will settle and close the channel according to the given final state.
[0100] When user A or user B does not cooperate (assuming it is user A, for example, no signature is returned), user B can submit the state with the highest (latest) version number and signed by both parties to the arbitration contract on the main chain. After the arbitration contract receives the state, user A can submit a state with a higher version number during the challenge period. After the challenge period ends, the state with the highest version number and signed by both parties received by the arbitration contract is the latest valid state.
[0101] In order to continue to execute the contract, User B can deploy Contract CT to the main chain and send the latest valid status determined by the arbitration contract to Contract CT. After that, User A and User B can jointly execute Contract CT on the main chain. After the contract is executed, the final status obtained will be sent to the arbitration contract. The arbitration contract will send the final status to the channel management contracts of Rollups chain A and Rollups chain B through the Rollups message mechanism. After receiving the final status, the channel management contract will settle according to the final status and close the channel.
[0102] The above implementation is only used to illustrate the technical solution of the present invention rather than to limit it. Ordinary technicians in this field can modify or replace the technical solution of the present invention with equivalents without departing from the scope of the present invention. The protection scope of the present invention shall be based on the claims.
Claims
1. A cross-chain smart contract fast execution method for Rollups chain, characterized in that: The method comprises: For contracts that require cross-chain execution Each participant builds a cross-Rollups chain state channel under the chain and transfers the state that needs to cross the chain and assets locked in the contract Among them, the contract that needs to be executed across chains , each participant builds a cross-Rollups chain state channel under the chain, including: All parties jointly sign the state channel across the Rollups chain ;in, Representation state channel The ID set of all Rollups chains involved, It's a contract Address, It is a challenging period; ID set of each participating direction The channel management contracts of all specified Rollups chains submit jointly signed state channels ; Each participant is based on the status of the Execution of the contract , get the updated status , and use the cross-Rollups chain state channel to perform state consensus; among them, is a natural number, and each participant is based on the status Execution of the contract , get the updated status , and use the cross-Rollups chain state channel to perform state consensus, including: One party based on the contract Address and status Execution of the contract , get the updated status ; Based on the cross-Rollups chain state channel, other participants will and an incremental version identifier; wherein the incremental version identifier includes a status and increment the version number ; When the participant collects the updated status of other participants After signing, proceed to status Updates; Each party has a status After reaching consensus, the status of each participant in the chain will be updated to , and based on the state Continue to execute the contract , until all parties agree to close the cross-Rollups chain state channel; Close the cross-Rollups chain state channel and perform settlement based on the latest status.
2. The method according to claim 1, characterized in that Closing the cross-Rollups chain state channel and performing settlement based on the latest state includes: When both parties agree to close the channel, each party signs the latest status and the closed channel tag; Send the latest status of the co-signature and the closed channel tag to the ID collection Specify the channel management contracts of all Rollups chains so that each channel management contract allocates assets according to the asset balance specified in the latest status.
3. The method according to claim 1, characterized in that The method further comprises: The parties involved cannot When consensus is reached, the final state of resolving the dispute is obtained through the arbitration contract deployed on the main chain. ; The contract Deployed on the main chain and based on the final state on the main chain Complete the contract the enforcement of ID Collection The channel management contracts of all specified Rollups chains are based on enforcing the final state of the output proceed to checkout.
4. The method according to claim 3, characterized in that The final state of resolving the dispute is obtained through the arbitration contract deployed on the main chain ,include: Any party submits status and challenge period to the referee contract deployed on the main chain; where the state The latest status signed by all parties; The party sends a dispute resolution start transaction to the ID set All specified Rollups chains; Any other party who initiates a transaction based on the dispute resolution during the challenge period Use the latest state signed by all parties Regarding the status Conduct a challenge; In the state The version number is higher than the state In the case, based on the status Regarding the status To cover; Output the final status of dispute resolution .
5. The method according to claim 3, characterized in that: Based on the final state on the main chain Complete the contract enforcement, including: The final state As a main chain contract The initial state of Each participant executes the contract on the main chain , and get the final state .
6. The method according to claim 3, characterized in that The ID set The channel management contracts of all specified Rollups chains obtain the final state The process includes: contract The final state Send to referee contract; The final state of the referee contract Send to ID collection The channel management contract for all specified Rollups chains.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, which, when executed by the processor, implement the cross-chain smart contract fast execution method for Rollups chains as described in any one of claims 1 to 6.
