Multi-main-chain layer 2 network state tree, multi-main-chain cross-chain method
By configuring a user asset tree and cross-chain verification contract on a Layer 2 network, the problem of inconvenient user asset retrieval in multi-main-chain cross-chain solutions is solved, achieving efficient and secure multi-main-chain cross-chain transaction management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 黄璟雯
- Filing Date
- 2021-12-31
- Publication Date
- 2026-07-31
AI Technical Summary
In existing technologies, cross-chain solutions where one Layer 2 network corresponds to multiple main chains result in inconvenience for users in retrieving assets and make it difficult to efficiently manage and retrieve users' assets across multiple main chains.
By configuring asset trees corresponding to each user's assets on each main chain on the second-layer network, and using zero-knowledge proof circuits and cross-chain verification contracts to synchronize and verify transaction information, user root hashes and second-layer network tree roots are generated, thus realizing a multi-main-chain cross-chain method.
It improves the convenience of user asset retrieval, ensures the correctness of transaction order and information, reduces data volume, saves costs, and prevents double-spending attacks.
Smart Images

Figure CN114219646B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of blockchain technology, specifically to a multi-master chain two-layer network state tree and a multi-master chain cross-chain method. Background Technology
[0002] Current cross-chain solutions based on Layer 2 networks are generally one-to-one, with one Layer 2 network corresponding to one main chain. The applicant seeks to propose a cross-chain solution where one Layer 2 network corresponds to multiple main chains.
[0003] When combining existing technologies with cross-chain solutions where one layer 2 network corresponds to multiple main chains, a relatively easy tree structure to construct is to build the state tree of the layer 2 network as a structure where one main chain corresponds to one tree. In this structure, if a user has assets configured on multiple main chains, the user account needs to be configured on the tree corresponding to each main chain, which is not very conducive to user asset retrieval. Summary of the Invention
[0004] In view of the above-mentioned defects or deficiencies in the existing technology, it is desirable to provide a multi-master chain layer 2 network state tree and multi-master chain cross-chain method that is more conducive to user asset retrieval.
[0005] In a first aspect, the present invention provides a multi-main-chain layer 2 network state tree, wherein the layer 2 network is configured with asset trees corresponding to each user in each main chain, and the root of the layer 2 network tree is generated according to the first user root hash of each first user, and the first user root hash is generated according to the first asset tree root of the first user in each main chain.
[0006] Secondly, the present invention provides a multi-master chain cross-chain method applicable to nodes in a Layer 2 network. The Layer 2 network is configured with the multi-master chain Layer 2 network state tree described in the first aspect. Each master chain is configured with a cross-chain verification contract and an oracle contract. The cross-chain verification contract deploys a zero-knowledge proof circuit for verifying transaction information, including:
[0007] Upon detecting the generation of the first main chain block, the first transactions requiring calls to the first type of contract within the first main chain block are synchronized sequentially; the first type of contract includes deposit contracts and withdrawal contracts; each first transaction is stored on the first main chain, and the first main chain block is also used for oracles.
[0008] The first transaction information of each first transaction in sequence is sent to other main chains so that the main chain nodes of other main chains can store the first transaction information through the oracle contract.
[0009] Execute each first transaction to update the asset tree of the second user who initiated the first transaction on the Layer 2 network, the second user's second user root hash, and the Layer 2 network tree root;
[0010] In response to the triggering of settlement conditions, zero-knowledge proof evidence is generated sequentially based on the second transaction information of each second transaction, and first proof data is generated based on each second transaction and the zero-knowledge proof evidence in sequence.
[0011] The first proof data is sent to each main chain for use by the main chain nodes:
[0012] The cross-chain verification contract is used to determine whether the order of the second transactions in the first proof data matches the stored information of the second transactions, thereby verifying whether the order of the second transactions in the first proof data is correct.
[0013] If the order is correct, the zero-knowledge proof evidence is input into the zero-knowledge proof circuit to verify the correctness of each second transaction piece of information:
[0014] If the verification is successful, the process ends.
[0015] The first and second transaction information include the operation type, user address, and number of tokens.
[0016] Thirdly, the present invention also provides an apparatus comprising one or more processors and a memory, wherein the memory contains instructions executable by the one or more processors to cause the one or more processors to perform a multi-master chain cross-chain method provided according to various embodiments of the present invention.
[0017] Fourthly, the present invention also provides a storage medium storing a computer program that enables a computer to execute a multi-master chain cross-chain method provided according to various embodiments of the present invention.
[0018] The multi-main-chain layer 2 network state tree and multi-main-chain cross-chain method provided by various embodiments of the present invention are configured with asset trees corresponding to each user on each main chain on the layer 2 network. The root of the layer 2 network tree is generated according to the first user root hash of each first user. The first user root hash is generated according to the first asset tree root of the first user on each main chain, which makes it more convenient for users to retrieve assets. Attached Figure Description
[0019] Other features, objects, and advantages of this application will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0020] Figure 1 This is a schematic diagram of a state tree for a multi-master chain two-layer network.
[0021] Figure 2 This is a schematic diagram of a multi-master chain two-layer network state tree provided in an embodiment of the present invention.
[0022] Figure 3 This is a flowchart of a multi-master chain cross-chain method provided in an embodiment of the present invention.
[0023] Figure 4 This is a schematic diagram of the structure of a device provided in an embodiment of the present invention. Detailed Implementation
[0024] The present application will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings.
[0025] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0026] Current cross-chain solutions based on Layer 2 networks are generally one-to-one, with one Layer 2 network corresponding to one main chain. The applicant aims to propose a cross-chain solution where one Layer 2 network corresponds to multiple main chains. Combining existing technologies with cross-chain solutions where one Layer 2 network corresponds to multiple main chains makes it relatively easy to construct solutions such as... Figure 1 The tree structure shown. Figure 1 This is a schematic diagram of a state tree for a multi-main-chain two-layer network. For example... Figure 1 As shown, the state tree of the two-layer network is constructed as a structure where one main chain corresponds to one tree.
[0027] Assume there are several main chains (chain A, chain B, chain C, etc.); chain A runs assets token A1 and token A2, chain B runs assets token B1 and token B2, chain C runs assets, etc.; users A, B, etc. hold token A1;
[0028] like Figure 1 As shown, the two-layer network has a state tree TreeA for chain A, a state tree TreeB for chain B, a state tree TreeC for chain C, and so on.
[0029] It can be seen that the ID root of tokenA1 is generated based on the balance of tokenA1 held by users such as user A and user B; the root of chain A is generated from the ID root of tokenA1, the ID root of tokenA2, etc.; the root is generated based on the root of chain A, the root of chain B, etc.
[0030] If user A holds token B1 on chain B and token C1 on chain C, then user accounts need to be configured on both TreeB and TreeC.
[0031] When user A needs to retrieve assets, they have to search through TreeA, TreeB, TreeC, etc., which is very inconvenient.
[0032] Figure 2 This is a schematic diagram of a multi-master chain two-layer network state tree provided in an embodiment of the present invention. Figure 2 As shown, in this embodiment, the present invention provides a multi-main-chain layer 2 network state tree. The layer 2 network is configured with asset trees corresponding to each user in each main chain. The root of the layer 2 network tree is generated according to the first user root hash of each first user. The first user root hash is generated according to the first asset tree root of the first user in each main chain.
[0033] Specifically, the first asset tree root is generated based on the account balance of each token on the first main chain where the first asset tree root is located, for example.
[0034] Similarly, assume there are several main chains (chain A, chain B, chain C, etc.); assets token A1 and token A2 are running on chain A, assets token B1 and token B2 are running on chain B, assets ... are running on chain C; user A holds token A1 and token A2.
[0035] like Figure 2 As shown, taking user A as an example, the Layer 2 network is configured with user A's asset tree on chain A, asset tree on chain B, asset tree on chain C, etc. The root of the Layer 2 network tree is generated based on the root hash of each user (i.e., user A's idroot, user B's idroot, user C's idroot, etc.). User A's idroot is generated based on the asset tree roots of each main chain's asset tree (i.e., chain A root, chain B root, chain C root, etc.). The asset tree root (taking chain A root as an example) is generated based on user A's account balance of each token in the asset tree on chain A (i.e., tokenA1 id balance, tokenA2 id balance, etc.).
[0036] When User A needs to retrieve assets, they can directly search for them on User A's A-chain asset tree, which is very convenient.
[0037] Figure 3 This is a flowchart illustrating a multi-main-chain cross-chain method according to an embodiment of the present invention. Figure 3 As shown, in this embodiment, the present invention provides a multi-master chain cross-chain method suitable for nodes in a Layer 2 network, wherein the Layer 2 network is configured with... Figure 2 The multi-chain layer-2 network state tree shown has cross-chain verification contracts and oracle contracts configured on each chain. The cross-chain verification contracts deploy zero-knowledge proof circuits for verifying transaction information, including:
[0038] S11: Upon detecting the generation of the first main chain block, synchronize the first transactions in the first main chain block that require invoking the first type of contract in sequence; among which, the first type of contract includes deposit contracts and withdrawal contracts; each first transaction is stored on the first main chain, and the first main chain block is also used for oracles:
[0039] The first transaction information of each first transaction in sequence is sent to other main chains so that the main chain nodes of other main chains can store the first transaction information through the oracle contract.
[0040] S12: Execute each first transaction to update the asset tree of the second user who initiated the first transaction on the Layer 2 network, the second user's second user root hash, and the Layer 2 network tree root;
[0041] S13: In response to the triggering of the settlement condition, generate zero-knowledge proof evidence in sequence based on the second transaction information of each second transaction, and generate first proof data based on each second transaction and the zero-knowledge proof evidence in sequence;
[0042] S14: Send the first proof data to each main chain for use by the main chain nodes:
[0043] The cross-chain verification contract is used to determine whether the order of the second transactions in the first proof data matches the stored information of the second transactions, thereby verifying whether the order of the second transactions in the first proof data is correct.
[0044] If the order is correct, the zero-knowledge proof evidence is input into the zero-knowledge proof circuit to verify the correctness of each second transaction piece of information:
[0045] If the verification is successful, the process ends.
[0046] The first and second transaction information include the operation type, user address, and number of tokens.
[0047] Assume there are 3 main chains (chain A, chain B, and chain C). Chain A runs asset tokens A1 and A2, chain B runs asset tokens B1 and B2, and chain C runs asset token C. The first main chain is chain A. The main chain nodes of chain A generate main chain block (100) in sequence according to tx1 to tx10. Among them, tx1 and tx2 are transactions that need to call the first type of contract.
[0048] The main chain node of chain A generates a main chain block (100) including tx1 and tx2, and tx1 and tx2 are stored on chain A.
[0049] The nodes of the second-layer network execute step S11. When they detect that block(100) has been generated in chain A, they synchronize tx1 and tx2 in sequence.
[0050] When the oracle detects that block (100) is generated on Chain A, it generates tx3 based on the transaction information of tx1 (deposit, addr(A), 100, tokenA1) and the transaction information of tx2 (withdraw, addr(B), 10, tokenA2), and sends tx3 to Chain B and Chain C;
[0051] The main chain nodes of Chain B and Chain C execute tx3 through the oracle contract. When tx3 is successfully executed, it deposits (deposit, addr(A), 100, tokenA1) and (withdraw, addr(B), 10, tokenA2);
[0052] The nodes in the second-layer network execute step S12. Taking tx1 as an example, execute tx1 to update the asset tree of user A on the second-layer network (i.e., update the tokenA1 id balance of user A and the root of Chain A of user A), the root hash of user A (i.e., the id root of user A), and the root of the second-layer network root; Similarly, execute tx2 to update the asset tree of user B on the second-layer network (i.e., update the tokenA2 id balance of user B and the root of Chain A of user B), the root hash of user B (i.e., the id root of user B), and the root of the second-layer network root;
[0053] Assume that the second transactions in order are tx1, tx2, tx11~tx20;
[0054] In response to triggering the settlement condition, the nodes in the second-layer network execute step S13, generate the zero-knowledge proof evidence proof1 according to the transaction information of tx1, tx2, tx11~tx20 in order, and generate the proof data proofchunk1 according to tx1, tx2, tx11~tx20, proof1; In more embodiments, the triggering settlement condition can be configured according to actual needs. For example, it can be configured to trigger when the first time period has elapsed since the last settlement, or it can be configured to trigger when a settlement request is received, and the same technical effect can be achieved;
[0055] The nodes in the second-layer network execute step S14 and send proofchunk1 to Chain A, Chain B, and Chain C;
[0056] The main chain nodes of Chain A, Chain B, and Chain C judge whether the order of tx1, tx2, tx11~tx20 in proofchunk1 matches the stored transaction information of tx1, tx2, tx11~tx20 through the cross-chain verification contract to verify whether the order of tx1, tx2, tx11~tx20 in proofchunk1 is correct:
[0057] Assuming the order is correct, the main chain nodes of chains A, B, and C will input proof1 into the zero-knowledge proof circuit to verify whether the transaction information of tx1, tx2, and tx11 to tx20 is correct:
[0058] If the verification is correct, then we will end here.
[0059] It should be noted that tx1 and tx2 are transactions synchronized from chain A, and assuming that tx11 to tx20 are transactions synchronized from chain B, then:
[0060] For Chain A, the main chain nodes of each main chain determine whether the order of tx1 and tx2 in proofchunk1 matches the transaction information of tx1 and tx2 stored in the proofchunk1 to verify whether the order of each transaction synchronized from Chain A in proofchunk1 is correct.
[0061] For the B chain, the main chain nodes of each main chain determine whether the order of tx11 to tx20 in proofchunk1 matches the transaction information of tx11 to tx20 stored in the proofchunk1 to verify whether the order of each transaction synchronized from the B chain in proofchunk1 is correct.
[0062] Assuming the transactions in proofchunk1 are tx1, tx11, tx2, tx12 to tx20, as long as the transaction information stored by the main chain nodes of each main chain is in the order of tx1→tx2 for tx1 and tx11→tx20 for tx11 to tx20, the verification order of the main chain nodes of each main chain is also correct.
[0063] The above embodiments enable multiple main chains to maintain a common ledger on the Layer 2 network, saving costs; and the Layer 2 network can only continue to operate normally if the transaction order and transaction information are correct, preventing double-spending.
[0064] Preferably, the above method further includes:
[0065] If an incorrect sequence or incorrect verification is detected, the state tree of each main chain on the Layer 2 network is rolled back to the state before each second transaction was executed.
[0066] Return to the step of generating zero-knowledge proof evidence in sequence based on the second transaction information of each second transaction, so as to regenerate the zero-knowledge proof evidence and the first proof data.
[0067] When the sequence of chains A, B, and C is incorrect, or the verification is incorrect, the nodes of the Layer 2 network roll back each user's asset tree to the state before tx1, tx2, tx11~tx20 were executed.
[0068] The nodes in the second-layer network return the step of "generating zero-knowledge proof evidence in sequence based on the second transaction information of each second transaction" to regenerate proof1 and proofchunk1;
[0069] Those skilled in the art should understand that if tx21 is also executed on the Layer 2 network, and the execution of tx21 requires the execution results of one or more transactions from tx1, tx2, tx11 to tx20, then tx21 should also be rolled back when rolling back each user's asset tree.
[0070] Preferably, before generating zero-knowledge proof evidence sequentially based on the second transaction information of each second transaction, the process further includes:
[0071] It receives third transactions generated by several clients that require invoking a second type of contract; the second type of contract includes transfer contracts and cross-chain transfer contracts.
[0072] Perform the following operations on each third transaction: Execute the third transaction to update the asset tree of the third user as the transaction initiator, the asset tree of the fourth user as the transaction recipient, the third user's third user root hash, the fourth user's fourth user root hash, and the second-layer network tree root on the second-layer network;
[0073] The cross-chain verification contract is used to determine whether the order of the second transactions in the first proof data matches the stored information of the second transactions, in order to verify whether the order of the second transactions in the first proof data is correct. This includes:
[0074] The cross-chain verification contract is used to determine whether the order of the second transactions in the first proof data (excluding the third transaction) matches the information of the second transactions stored in the proof data, thereby verifying whether the order of the second transactions in the first proof data is correct.
[0075] Specifically, the main chain nodes of this application are configured to receive transactions of the first type of contract generated by the client, while the nodes of the second-layer network are configured to receive transactions of the second type of contract generated by the client.
[0076] Combination Figure 3 In the illustrated embodiment, assuming tx11 to tx15 are the third transactions calling the second type of contract, and tx16 to tx20 are the first transactions calling the first type of contract synchronized from block (101) of chain A; it can be seen that the nodes of the second-layer network first synchronized tx1 and tx2 from block (100) of chain A, then received tx11 to tx15 in sequence, and then synchronized tx16 to tx20 in sequence from block (101) of chain A; therefore, the order of each transaction is tx1, tx2, tx11 to tx20; correspondingly, the oracle sends the transaction information of tx1, tx2, tx11 to tx20 in sequence.
[0077] For tx1, tx2, tx11~tx20: The main chain nodes of chains A, B, and C only verify whether the order of tx1, tx2, tx16~tx20 is correct.
[0078] Those skilled in the art should understand that the transaction information for a third transaction that invokes a second type of contract should also include the asset type.
[0079] Preferably, the generation of first proof data based on each second transaction and zero-knowledge proof evidence in sequence includes:
[0080] The first proof data is generated based on the sequential second transactions, the second-layer network root, and the zero-knowledge proof evidence.
[0081] The cross-chain verification contract is used to determine whether the order of the second transactions in the first proof data matches the stored information of the second transactions, in order to verify whether the order of the second transactions in the first proof data is correct. This includes:
[0082] The cross-chain verification contract calculates the first root based on each second transaction and the previously stored second-layer network root. If the first root matches the second-layer network root, the stored second-layer network root is updated.
[0083] The cross-chain verification contract is used to determine whether the order of the second transactions in the first proof data matches the information of the second transactions stored in the proof data, thereby verifying whether the order of the second transactions in the first proof data is correct.
[0084] Specifically, proofchunk1 also includes root; assuming the value of root is R1;
[0085] The main chain nodes of chains A, B, and C, through a cross-chain verification contract, calculate root' based on tx1, tx2, tx11~tx20, and the previously stored root (i.e., the previous root, assuming its value is R2). The value of root' is assumed to be R3. If R1 = R3, the stored root value is updated from R2 to R1. And...
[0086] The cross-chain verification contract is used to determine whether the order of tx1, tx2, tx11 to tx20 in proofchunk1 matches the stored transaction information of tx1, tx2, tx11 to tx20, in order to verify whether the order of tx1, tx2, tx11 to tx20 in proofchunk1 is correct.
[0087] Preferably, nodes in the second-layer network deposit a certain amount of money on each main chain. When a main chain node detects an incorrect sequence or incorrect verification, it deducts the first amount of money from the deposit.
[0088] The above embodiments penalize nodes in the Layer 2 network to further prevent double-spending.
[0089] Preferably, the first transaction information of each first transaction in sequence is sent to other main chains so that the main chain nodes of other main chains can store the first transaction information through the oracle contract, including:
[0090] The first transaction information of each first transaction is stored in sequence. A fourth transaction is generated based on the first transaction information. The fourth transaction is sent to other main chains so that the main chain nodes of other main chains can execute the fourth transaction through the oracle contract. When the fourth transaction is successfully executed, the first transaction information is stored as evidence.
[0091] The above embodiments reduce the amount of data in the first proof data.
[0092] Preferably, the first transaction information stored through oracle contracts includes:
[0093] Store each first transaction information in the oracle contract;
[0094] The cross-chain verification contract is used to determine whether the order of the second transactions in the first proof data matches the stored information of the second transactions, in order to verify whether the order of the second transactions in the first proof data is correct. This includes:
[0095] The cross-chain verification contract requests the second transaction information from the oracle contract.
[0096] Determine whether the order of each second transaction in the first proof data matches the information of each second transaction stored in the proof data to verify whether the order of each second transaction in the first proof data is correct.
[0097] The above embodiments store the second transaction information in the oracle contract. In more embodiments, the permissions for other contracts to access the second transaction information can be configured according to actual needs. For example, the cross-chain verification contract can access the second transaction information, while some other contracts are configured not to access the second transaction information.
[0098] Preferably, the first transaction information of each first transaction in sequence is sent to other main chains, including:
[0099] The first transaction information of each first transaction is stored in sequence and sent to other main chains. The first transaction information is also used by the oracle to send the first transaction information to the first main chain node when it detects the first main chain node that has just joined the network, so that the first main chain node can store the first transaction information through the oracle contract.
[0100] The above embodiments accelerate the synchronization of main chain block data by newly joined main chain nodes and improve the accuracy of synchronized main chain block data.
[0101] Figure 4 This is a schematic diagram of the structure of a device provided in an embodiment of the present invention.
[0102] like Figure 4 As shown, in another aspect, this application also provides a device including one or more central processing units (CPUs) 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage portion 408 into a random access memory (RAM) 403. The RAM 403 also stores various programs and data required for the operation of the device 400. The CPU 401, ROM 402, and RAM 403 are interconnected via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0103] The following components are connected to I / O interface 405: an input section 406 including a keyboard, mouse, etc.; an output section 407 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 408 including a hard disk, etc.; and a communication section 409 including a network interface card such as a LAN card, modem, etc. The communication section 409 performs communication processing via a network such as the Internet. A drive 410 is also connected to I / O interface 405 as needed. A removable medium 411, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 410 as needed so that computer programs read from it can be installed into storage section 408 as needed.
[0104] In particular, according to embodiments of this disclosure, the methods described in any of the above embodiments can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program containing program code for performing any of the above methods. In such embodiments, the computer program can be downloaded and installed from a network via communication section 409, and / or installed from removable medium 411.
[0105] In another aspect, this application also provides a computer-readable storage medium, which may be a computer-readable storage medium included in the apparatus of the above embodiments; or it may be a standalone computer-readable storage medium not assembled into the device. The computer-readable storage medium stores one or more programs that are used by one or more processors to perform the methods described in this application.
[0106] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified function or operation, or by a combination of dedicated hardware and computer instructions.
[0107] The units or modules described in the embodiments of this application can be implemented in software or hardware. The described units or modules can also be located in a processor; for example, each unit can be a software program located in a computer or mobile smart device, or a separately configured hardware device. The names of these units or modules do not, in some cases, constitute a limitation on the unit or module itself.
[0108] The above description is merely a preferred embodiment of this application and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in this application is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the concept of this application. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in this application.
Claims
1. A multi-mainchain cross-chain method, characterized in that, The second-layer network is configured with a multi-main-chain second-layer network state tree. The second-layer network is configured with an asset tree corresponding to each user in each main chain. The root of the second-layer network tree is generated based on the first user's first user root hash. The first user root hash is generated based on the first asset tree root of the first user in each main chain. The first asset tree root is generated based on the account balance of each token of the first user on the first main chain where the first asset tree root is located; Each main chain is configured with a cross-chain verification contract and an oracle contract. The cross-chain verification contract deploys a zero-knowledge proof circuit for verifying transaction information. The method is applicable to nodes in a Layer 2 network and includes: Upon detecting the generation of the first main chain block, the first transactions requiring calls to the first type of contract within the first main chain block are synchronized sequentially; wherein, the first type of contract includes deposit contracts and withdrawal contracts; each of the first transactions is stored on the first main chain, and the first main chain block is also used to provide information to the oracle. The first transaction information of each of the first transactions in sequence is sent to other main chains so that the main chain nodes of other main chains can store the first transaction information through the oracle contract. Execute each of the first transactions to update the asset tree of the second user who initiated the first transaction on the Layer 2 network, the second user's second user root hash, and the root of the Layer 2 network tree; In response to the triggering of settlement conditions, zero-knowledge proof evidence is generated sequentially based on the second transaction information of each second transaction, and first proof data is generated based on each second transaction in sequence and the zero-knowledge proof evidence. The first proof data is sent to each main chain for use by the main chain nodes: The cross-chain verification contract determines whether the order of the second transactions in the first proof data matches the stored information of each second transaction, thereby verifying whether the order of the second transactions in the first proof data is correct. If the order is correct, the zero-knowledge proof evidence is input into the zero-knowledge proof circuit to verify whether each of the second transaction information is correct: If the verification is successful, the process ends. The first transaction information and the second transaction information include the operation type, user address, and number of tokens.
2. The method according to claim 1, characterized in that, Also includes: If an incorrect sequence or incorrect verification is detected, roll back each user's asset tree on the Layer 2 network to the state before each of the second transactions was executed; Return to the step of generating zero-knowledge proof evidence sequentially based on the second transaction information of each second transaction, to regenerate the zero-knowledge proof evidence and the first proof data.
3. The method according to claim 1, characterized in that, Before generating zero-knowledge proof evidence sequentially based on the second transaction information of each second transaction, the method further includes: Receives third transactions generated by several clients that require invoking a second type of contract; wherein, the second type of contract includes transfer contracts and cross-chain transfer contracts; For each of the third transactions, the following operations are performed: The third transaction is executed to update the asset tree of the third user as the transaction initiator, the asset tree of the fourth user as the transaction recipient, the third user's third user root hash, the fourth user's fourth user root hash, and the root of the second-layer network tree on the Layer 2 network; The step of determining whether the order of the second transactions in the first proof data matches the stored information of the second transactions through the cross-chain verification contract to verify whether the order of the second transactions in the first proof data is correct includes: The cross-chain verification contract determines whether the order of the second transactions in the first proof data (excluding the third transaction) matches the stored information of each of the second transactions, thereby verifying whether the order of the second transactions in the first proof data is correct.
4. The method according to claim 1, characterized in that, The step of generating the first proof data based on the sequential second transactions and the zero-knowledge proof evidence includes: First proof data is generated based on the sequential second transactions, the second-layer network root, and the zero-knowledge proof evidence; The cross-chain verification contract calculates the first root based on each second transaction and the previously stored second-layer network root. When the first root is identical to the second-layer network root, the stored second-layer network root is updated. The cross-chain verification contract determines whether the order of each second transaction in the first proof data matches the stored information of each second transaction, thereby verifying whether the order of each second transaction in the first proof data is correct.
5. The method according to claim 1, characterized in that, The step of sending the first transaction information of each of the first transactions in sequence to other main chains, so that the main chain nodes of other main chains can store the first transaction information through the oracle contract, includes: The first transaction information of each of the first transactions is stored in sequence. A fourth transaction is generated based on each of the first transaction information. The fourth transaction is sent to other main chains so that the main chain nodes of other main chains can execute the fourth transaction through the oracle contract. When the fourth transaction is successfully executed, the first transaction information is stored as evidence.
6. The method according to claim 5, characterized in that, The method of storing each of the first transaction information through the oracle contract includes: Each of the first transaction information is stored in the oracle contract; The cross-chain verification contract requests the second transaction information from the oracle contract. Determine whether the order of each second transaction in the first proof data matches the information of each second transaction stored in the proof data to verify whether the order of each second transaction in the first proof data is correct.
7. A computer device, characterized in that, The device includes: One or more processors; Memory, used to store one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors perform the method as described in any one of claims 1-6.
8. A storage medium storing a computer program, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-6.