Blockchain data processing method, apparatus, and device, computer-readable storage medium, and computer program product
Abstract
A blockchain data processing method is performed by an electronic device. The method includes: packaging a local consensus transaction, a main chain binding height, and a main chain read dataset into a local consensus block; broadcasting the local consensus block to a local verification node, where the local verification node is configured to obtain obtaining a voting consensus result corresponding to a transaction execution result of the local consensus transaction when a synchronized block height is greater than or equal to the main chain binding height, and a synchronized read dataset is consistent with the main chain read dataset; and uploading, when determining that consensus is reached based on the voting consensus result returned by the local verification node, the local consensus block to a local consensus sub-chain corresponding to a local consensus network.
Claims
exact text as granted — not AI-modifiedWhat is claimed is:
1. A blockchain data processing method, performed by an electronic device acting as a local consensus node in a local consensus network, the method comprising:
packaging a local consensus transaction, a main chain binding height, and a main chain read dataset into a local consensus block, the local consensus transaction being a service transaction executed in the local consensus network, wherein the local consensus network is deployed in a service network of a multi-layer chain network, and a core consensus network comprising a core consensus node is deployed in the multi-layer chain network and independent of the service network, and the main chain binding height being a block height of a first global consensus block, the first global consensus block being synchronized from a main chain of the core consensus node when packaging the local consensus transaction, the main chain read dataset being obtained by clearing from a first global contract state and being used for executing the local consensus transaction, and the first global contract state being a read dataset that is read when a global consensus transaction in the first global consensus block is executed;
broadcasting the local consensus block to a local verification node, the local verification node being configured to obtain a voting consensus result corresponding to a transaction execution result of the local consensus transaction when a synchronized block height is greater than or equal to the main chain binding height, and a synchronized read dataset is consistent with the main chain read dataset, and the local verification node being a consensus node other than the local consensus node in the local consensus network;
when determining that consensus is reached based on the voting consensus result returned by the local verification node, uploading the local consensus block to a local consensus sub-chain corresponding to the local consensus network, and writing the local consensus block into a local consensus ledger database;
invoking a local consensus service contract on the local consensus sub-chain to perform the following processing:
obtaining a target block height from a main chain sub-ledger database, wherein the target block height is a block height of a second global consensus block that is synchronized from the main chain through the core consensus node, and the second global consensus block is a global consensus block that is synchronized from the main chain when consensus on the local consensus block is reached;
searching, when the target block height is greater than or equal to the main chain binding height, a read dataset associated with the first global consensus block in the main chain sub-ledger database, to obtain a target read dataset; and
using a key-value pair in the target read dataset as a first key-value pair, using a key-value pair in the main chain read dataset as a second key-value pair, and executing, when the first key-value pair is consistent with the second key-value pair, the local consensus transaction in the local consensus block, to obtain the transaction execution result.
2. The method according to claim 1 , wherein after the obtaining a target block height from a main chain sub-ledger database, the method further comprises:
canceling review of the main chain read dataset when the target block height is less than the main chain binding height.
3. The method according to claim 1 , wherein after the using a key-value pair in the target read dataset as a first key-value pair, and using a key-value pair in the main chain read dataset as a second key-value pair, the method further comprises:
canceling execution of the local consensus transaction when the first key-value pair is inconsistent with the second key-value pair.
4. The method according to claim 1 , wherein the method further comprises:
invoking a main chain clearing and synchronization component to generate a main chain clearing and synchronization request, wherein the main chain clearing and synchronization request carries the block height of the first global consensus block;
transmitting the main chain clearing and synchronization request to the core consensus node, wherein the main chain clearing and synchronization request is used for indicating the core consensus node to determine a global consensus block whose block height is greater than the block height of the first global consensus block as a global consensus block that is on the main chain and that is not synchronized to the local consensus node, and select a to-be-synchronized global block from the global consensus block that is not synchronized to the local consensus node; and
receiving the to-be-synchronized global block returned by the core consensus node, and using the to-be-synchronized global block as the second global consensus block.
5. The method according to claim 1 , wherein the method further comprises:
obtaining, when packaging the local consensus transaction, a maximum global block height and a global consensus block corresponding to the maximum global block height from the main chain through the core consensus node; and
using the global consensus block corresponding to the maximum global block height as the first global consensus block, and using the maximum global block height as the main chain binding height.
6. The method according to claim 1 , wherein the method further comprises:
obtaining a sub-chain clearing and synchronization request transmitted by a local service node, wherein the local service node comprises a local chain sub-ledger database, the sub-chain clearing and synchronization request carries a local block height synchronized by the local service node from the local consensus sub-chain, the local consensus sub-chain is a blockchain of the local consensus node, and the local block height is a block height of the local consensus block;
determining a local consensus block whose block height is greater than the local block height on the local consensus sub-chain as a local consensus block that is not synchronized to the local service node, and selecting a target local block from the local consensus block that is not synchronized to the local service node; and
obtaining a local contract state of the target local block, and returning the target local block and the local contract state to the local service node, wherein the local service node is configured to write the target local block and the local contract state into the local chain sub-ledger database, wherein the local contract state is a read dataset read by executing a local consensus transaction in the target local block, and the local consensus transaction is executed by the local consensus service contract on the local consensus sub-chain of the local consensus network.
7. The method according to claim 1 , wherein the method further comprises:
synchronizing a target consensus block comprising a registration transaction from the main chain, wherein the registration transaction is a service transaction that applies to the core consensus node to register the local consensus sub-chain, a configuration transaction corresponding to the registration transaction is written in the target consensus block, and the configuration transaction carries configuration information;
obtaining the configuration information from the target consensus block, and creating, when the configuration information is consistent with information configured by the local consensus node, a genesis block in the local consensus network; and
starting the local consensus sub-chain based on the genesis block.
8. The method according to claim 1 , wherein the method further comprises:
clearing, when synchronizing a first block from the main chain, an archiving task event of the local consensus sub-chain from the first block, wherein the first block comprises an archiving configuration transaction associated with the archiving task event; the archiving configuration transaction is determined by an archiving task command triggered by a service object; and the archiving task command is used for archiving local consensus data on the local consensus sub-chain;
transmitting, when the archiving task command indicated by the archiving task event is a ledger archiving command based on the ledger archiving command, a block data digest of an archiving block on the local consensus sub-chain to the core consensus node, wherein the core consensus node is configured to package packaging a first digest confirmation event of the block data digest into a second block, and writing the second block into the main chain;
synchronizing the second block from the main chain, and when the first digest confirmation event is obtained by clearing from the second block, determining to-be-backed up ledger data based on a transaction original text in the archiving block, and transmitting the to-be-backed up ledger data to a remote backup device of the multi-layer chain network, wherein the remote backup device is configured to back up the to-be-backed up ledger data, to obtain ledger backup information; and
forwarding a first backup signature transmitted by the remote backup device to the core consensus node, wherein the core consensus node is configured to determine, when determining that the first backup signature is generated by the remote backup device and a ledger backup data digest of the ledger backup information is consistent with the block data digest, that the to-be-backed up ledger data has been backed up to the remote backup device.
9. An electronic device acting as a local consensus node in a local consensus network, the electronic device comprising a processor and a memory,
the memory being connected to the processor, the memory being configured to store a computer program, and the processor being configured to invoke the computer program, to enable the electronic device to perform a blockchain data processing method including:
packaging a local consensus transaction, a main chain binding height, and a main chain read dataset into a local consensus block, the local consensus transaction being a service transaction executed in the local consensus network, wherein the local consensus network is deployed in a service network of a multi-layer chain network, and a core consensus network comprising a core consensus node is deployed in the multi-layer chain network and independent of the service network, and the main chain binding height being a block height of a first global consensus block, the first global consensus block being synchronized from a main chain of the core consensus node when packaging the local consensus transaction, the main chain read dataset being obtained by clearing from a first global contract state and being used for executing the local consensus transaction, and the first global contract state being a read dataset that is read when a global consensus transaction in the first global consensus block is executed;
broadcasting the local consensus block to a local verification node, the local verification node being configured to obtain a voting consensus result corresponding to a transaction execution result of the local consensus transaction when a synchronized block height is greater than or equal to the main chain binding height, and a synchronized read dataset is consistent with the main chain read dataset, and the local verification node being a consensus node other than the local consensus node in the local consensus network;
when determining that consensus is reached based on the voting consensus result returned by the local verification node, uploading the local consensus block to a local consensus sub-chain corresponding to the local consensus network, and writing the local consensus block into a local consensus ledger database;
invoking a local consensus service contract on the local consensus sub-chain to perform the following processing:
obtaining a target block height from a main chain sub-ledger database, wherein the target block height is a block height of a second global consensus block that is synchronized from the main chain through the core consensus node, and the second global consensus block is a global consensus block that is synchronized from the main chain when consensus on the local consensus block is reached;
searching, when the target block height is greater than or equal to the main chain binding height, a read dataset associated with the first global consensus block in the main chain sub-ledger database, to obtain a target read dataset; and
using a key-value pair in the target read dataset as a first key-value pair, using a key-value pair in the main chain read dataset as a second key-value pair, and executing, when the first key-value pair is consistent with the second key-value pair, the local consensus transaction in the local consensus block, to obtain the transaction execution result.
10. The electronic device according to claim 9 , wherein after the obtaining a target block height from a main chain sub-ledger database, the method further comprises:
canceling review of the main chain read dataset when the target block height is less than the main chain binding height.
11. The electronic device according to claim 9 , wherein after the using a key-value pair in the target read dataset as a first key-value pair, and using a key-value pair in the main chain read dataset as a second key-value pair, the method further comprises:
canceling execution of the local consensus transaction when the first key-value pair is inconsistent with the second key-value pair.
12. The electronic device according to claim 9 , wherein the method further comprises:
invoking a main chain clearing and synchronization component to generate a main chain clearing and synchronization request, wherein the main chain clearing and synchronization request carries the block height of the first global consensus block;
transmitting the main chain clearing and synchronization request to the core consensus node, wherein the main chain clearing and synchronization request is used for indicating the core consensus node to determine a global consensus block whose block height is greater than the block height of the first global consensus block as a global consensus block that is on the main chain and that is not synchronized to the local consensus node, and select a to-be-synchronized global block from the global consensus block that is not synchronized to the local consensus node; and
receiving the to-be-synchronized global block returned by the core consensus node, and using the to-be-synchronized global block as the second global consensus block.
13. The electronic device according to claim 9 , wherein the method further comprises:
obtaining, when packaging the local consensus transaction, a maximum global block height and a global consensus block corresponding to the maximum global block height from the main chain through the core consensus node; and
using the global consensus block corresponding to the maximum global block height as the first global consensus block, and using the maximum global block height as the main chain binding height.
14. The electronic device according to claim 9 , wherein the method further comprises:
obtaining a sub-chain clearing and synchronization request transmitted by a local service node, wherein the local service node comprises a local chain sub-ledger database, the sub-chain clearing and synchronization request carries a local block height synchronized by the local service node from the local consensus sub-chain, the local consensus sub-chain is a blockchain of the local consensus node, and the local block height is a block height of the local consensus block;
determining a local consensus block whose block height is greater than the local block height on the local consensus sub-chain as a local consensus block that is not synchronized to the local service node, and selecting a target local block from the local consensus block that is not synchronized to the local service node; and
obtaining a local contract state of the target local block, and returning the target local block and the local contract state to the local service node, wherein the local service node is configured to write the target local block and the local contract state into the local chain sub-ledger database, wherein the local contract state is a read dataset read by executing a local consensus transaction in the target local block, and the local consensus transaction is executed by the local consensus service contract on the local consensus sub-chain of the local consensus network.
15. The electronic device according to claim 9 , wherein the method further comprises:
synchronizing a target consensus block comprising a registration transaction from the main chain, wherein the registration transaction is a service transaction that applies to the core consensus node to register the local consensus sub-chain, a configuration transaction corresponding to the registration transaction is written in the target consensus block, and the configuration transaction carries configuration information;
obtaining the configuration information from the target consensus block, and creating, when the configuration information is consistent with information configured by the local consensus node, a genesis block in the local consensus network; and
starting the local consensus sub-chain based on the genesis block.
16. The electronic device according to claim 9 , wherein the method further comprises:
clearing, when synchronizing a first block from the main chain, an archiving task event of the local consensus sub-chain from the first block, wherein the first block comprises an archiving configuration transaction associated with the archiving task event; the archiving configuration transaction is determined by an archiving task command triggered by a service object; and the archiving task command is used for archiving local consensus data on the local consensus sub-chain;
transmitting, when the archiving task command indicated by the archiving task event is a ledger archiving command based on the ledger archiving command, a block data digest of an archiving block on the local consensus sub-chain to the core consensus node, wherein the core consensus node is configured to package packaging a first digest confirmation event of the block data digest into a second block, and writing the second block into the main chain;
synchronizing the second block from the main chain, and when the first digest confirmation event is obtained by clearing from the second block, determining to-be-backed up ledger data based on a transaction original text in the archiving block, and transmitting the to-be-backed up ledger data to a remote backup device of the multi-layer chain network, wherein the remote backup device is configured to back up the to-be-backed up ledger data, to obtain ledger backup information; and
forwarding a first backup signature transmitted by the remote backup device to the core consensus node, wherein the core consensus node is configured to determine, when determining that the first backup signature is generated by the remote backup device and a ledger backup data digest of the ledger backup information is consistent with the block data digest, that the to-be-backed up ledger data has been backed up to the remote backup device.
17. A non-transitory computer-readable storage medium, storing a computer program, the computer program that, when executed by a processor of an electronic device acting as a local consensus node in a local consensus network, enabling the electronic device to perform a blockchain data processing method including:
packaging a local consensus transaction, a main chain binding height, and a main chain read dataset into a local consensus block, the local consensus transaction being a service transaction executed in the local consensus network, wherein the local consensus network is deployed in a service network of a multi-layer chain network, and a core consensus network comprising a core consensus node is deployed in the multi-layer chain network and independent of the service network, and the main chain binding height being a block height of a first global consensus block, the first global consensus block being synchronized from a main chain of the core consensus node when packaging the local consensus transaction, the main chain read dataset being obtained by clearing from a first global contract state and being used for executing the local consensus transaction, and the first global contract state being a read dataset that is read when a global consensus transaction in the first global consensus block is executed;
broadcasting the local consensus block to a local verification node, the local verification node being configured to obtain a voting consensus result corresponding to a transaction execution result of the local consensus transaction when a synchronized block height is greater than or equal to the main chain binding height, and a synchronized read dataset is consistent with the main chain read dataset, and the local verification node being a consensus node other than the local consensus node in the local consensus network;
when determining that consensus is reached based on the voting consensus result returned by the local verification node, uploading the local consensus block to a local consensus sub-chain corresponding to the local consensus network, and writing the local consensus block into a local consensus ledger database;
invoking a local consensus service contract on the local consensus sub-chain to perform the following processing:
obtaining a target block height from a main chain sub-ledger database, wherein the target block height is a block height of a second global consensus block that is synchronized from the main chain through the core consensus node, and the second global consensus block is a global consensus block that is synchronized from the main chain when consensus on the local consensus block is reached;
searching, when the target block height is greater than or equal to the main chain binding height, a read dataset associated with the first global consensus block in the main chain sub-ledger database, to obtain a target read dataset; and
using a key-value pair in the target read dataset as a first key-value pair, using a key-value pair in the main chain read dataset as a second key-value pair, and executing, when the first key-value pair is consistent with the second key-value pair, the local consensus transaction in the local consensus block, to obtain the transaction execution result.
18. The non-transitory computer-readable storage medium according to claim 17 , wherein the method further comprises:
obtaining, when packaging the local consensus transaction, a maximum global block height and a global consensus block corresponding to the maximum global block height from the main chain through the core consensus node; and
using the global consensus block corresponding to the maximum global block height as the first global consensus block, and using the maximum global block height as the main chain binding height.
19. The non-transitory computer-readable storage medium according to claim 17 , wherein the method further comprises:
obtaining a sub-chain clearing and synchronization request transmitted by a local service node, wherein the local service node comprises a local chain sub-ledger database, the sub-chain clearing and synchronization request carries a local block height synchronized by the local service node from the local consensus sub-chain, the local consensus sub-chain is a blockchain of the local consensus node, and the local block height is a block height of the local consensus block;
determining a local consensus block whose block height is greater than the local block height on the local consensus sub-chain as a local consensus block that is not synchronized to the local service node, and selecting a target local block from the local consensus block that is not synchronized to the local service node; and
obtaining a local contract state of the target local block, and returning the target local block and the local contract state to the local service node, wherein the local service node is configured to write the target local block and the local contract state into the local chain sub-ledger database, wherein the local contract state is a read dataset read by executing a local consensus transaction in the target local block, and the local consensus transaction is executed by the local consensus service contract on the local consensus sub-chain of the local consensus network.
20. The non-transitory computer-readable storage medium according to claim 17 , wherein the method further comprises:
synchronizing a target consensus block comprising a registration transaction from the main chain, wherein the registration transaction is a service transaction that applies to the core consensus node to register the local consensus sub-chain, a configuration transaction corresponding to the registration transaction is written in the target consensus block, and the configuration transaction carries configuration information;
obtaining the configuration information from the target consensus block, and creating, when the configuration information is consistent with information configured by the local consensus node, a genesis block in the local consensus network; and
starting the local consensus sub-chain based on the genesis block.Cited by (0)
No later patents cite this yet.
References (0)
No backward citations on record.