CN115114372A - Data processing method, device and equipment based on block chain and readable storage medium - Google Patents

Data processing method, device and equipment based on block chain and readable storage medium Download PDF

Info

Publication number
CN115114372A
CN115114372A CN202210609432.7A CN202210609432A CN115114372A CN 115114372 A CN115114372 A CN 115114372A CN 202210609432 A CN202210609432 A CN 202210609432A CN 115114372 A CN115114372 A CN 115114372A
Authority
CN
China
Prior art keywords
result
consensus
data
block
transaction
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210609432.7A
Other languages
Chinese (zh)
Inventor
刘长辉
庞哲维
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202210609432.7A priority Critical patent/CN115114372A/en
Publication of CN115114372A publication Critical patent/CN115114372A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3247Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving digital signatures

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Data Mining & Analysis (AREA)
  • Business, Economics & Management (AREA)
  • Finance (AREA)
  • Accounting & Taxation (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Economics (AREA)
  • Software Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Signal Processing (AREA)
  • Bioethics (AREA)
  • Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • Development Economics (AREA)
  • Computer Hardware Design (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • General Business, Economics & Management (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a data processing method, a device, equipment and a readable storage medium based on a block chain, wherein the method comprises the following steps: a first node receives an uplink request aiming at a block sent by a second node; acquiring a first pre-execution result of transaction data in a block based on the uplink request, and performing consensus on the block according to the first pre-execution result and a data integrity constraint rule indicated by the relational data model to obtain a consensus result of the block; the first pre-execution result is an execution result obtained after the first node pre-executes the transaction associated operation related to the transaction data based on the structured query language instruction corresponding to the transaction data; and when the consensus result of the block is a consensus passing result, storing the block into the relational database. By the method and the device, the flexibility of relation operation of the service data can be improved in the block chain service, and further the data processing efficiency and accuracy are improved.

Description

Data processing method, device and equipment based on block chain and readable storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a data processing method, apparatus, device, and readable storage medium based on a block chain.
Background
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like, is mainly used for sorting data according to a time sequence and encrypting the data into an account book, so that the data cannot be falsified or forged, and meanwhile, the data can be verified, stored and updated. The blockchain can also carry out data encryption transmission, node identification and safe access, and is an advanced distributed infrastructure. At present, the applications of block chains are increasing because of their non-tamper-ability and authenticity.
Typically, the blockchain stores data on the chain primarily in a key-value pair manner. For example, the Unspent Transaction Output (UTXO) data, the account data, and the Transaction status data may be stored by using a key.
However, the key value mode is a simpler data storage mode, and can process a simple service scenario, but with the expansion of blockchain applications, the association relationship between service data generated by the service scenario becomes more and more complex, and the simple key value storage mode is difficult to accurately describe the association relationship between the service data. If a complex association relation between business data is expected to be accurately described through a simple key value storage mode, a great number of data operations are required, the working efficiency is not high, and meanwhile, certain time and labor cost are increased.
Disclosure of Invention
Embodiments of the present application provide a data processing method, an apparatus, a device, and a readable storage medium based on a block chain, which can improve flexibility of relational operation of service data in a block chain service, thereby improving data processing efficiency and accuracy.
An embodiment of the present application provides a data processing method based on a block chain, including:
a first node receives an uplink request aiming at a block sent by a second node; the uplink request is used for requesting to store the block into a relational database corresponding to the block chain, wherein the relational database is established based on a relational data model;
acquiring a first pre-execution result of transaction data in a block based on the uplink request, and performing consensus on the block according to the first pre-execution result and a data integrity constraint rule indicated by the relational data model to obtain a consensus result of the block; the first pre-execution result is an execution result obtained after the first node pre-executes the transaction associated operation related to the transaction data based on the structured query language instruction corresponding to the transaction data; the structured query language instruction is an instruction for operating the relational database to execute transaction correlation operation;
and when the consensus result of the block is a consensus passing result, storing the block into the relational database.
An embodiment of the present application provides a data processing apparatus based on a block chain, including:
a request receiving module, configured to receive an uplink request for a block sent by a second node; the uplink request is used for requesting to store the block into a relational database corresponding to the block chain, wherein the relational database is established based on a relational data model;
an execution result obtaining module, configured to obtain a first pre-execution result of the transaction data in the block based on the uplink request;
the block consensus module is used for performing consensus on the blocks according to the first pre-execution result and the data integrity constraint rule indicated by the relation data model to obtain a consensus result of the blocks; the first pre-execution result is an execution result obtained after the first node pre-executes the transaction associated operation related to the transaction data based on the structured query language instruction corresponding to the transaction data; the structured query language instruction refers to an instruction for operating the relational database to execute transaction association operation;
and the block storage module is used for storing the blocks into the relational database when the consensus result of the blocks is a consensus passing result.
In one embodiment, the execution result obtaining module includes:
a transaction creation unit for creating an initial database transaction for a block based on the uplink request;
the instruction execution unit is used for executing a structured query language instruction indicated by transaction correlation operation in an initial database transaction to obtain an instruction execution result;
and the result determining unit is used for determining the instruction execution result as a first pre-execution result of the transaction data.
In one embodiment, the block storage module comprises:
a target transaction acquisition unit to acquire a target database transaction associated with a block; the target database transaction comprises a structured query language instruction in the transaction data and a first pre-execution result;
and the transaction storage unit is used for storing the target database transaction into the relational database.
In one embodiment, the uplink request carries a second pre-execution result, where the second pre-execution result is an execution result obtained after the second node performs pre-execution on the transaction relationship operation in the transaction data based on the structured query language instruction in the transaction data;
the block consensus module comprises:
the result comparison unit is used for comparing the first pre-execution result with the second pre-execution result to obtain a comparison result;
the factor common identification unit is used for acquiring a primary key value contained by the structured query language instruction, an external key value contained by the structured query language instruction and a data type corresponding to the structured query language instruction based on a data integrity constraint rule indicated by the relational data model if a comparison result between the first pre-execution result and the second pre-execution result is a matching result;
the factor consensus unit is also used for performing consensus on the primary key value, the foreign key value and the data type to obtain a factor consensus result corresponding to the primary key value, the foreign key value and the data type;
a first result determination unit for determining the factor consensus result as a consensus result of the blocks;
the second result determining unit is configured to determine that the consensus result of the block is a consensus failure result if the comparison result between the first pre-execution result and the second pre-execution result is a mismatch result.
In one embodiment, the number of the second nodes is at least two, and the number of the second pre-execution results is at least two;
the result comparison unit comprises:
the same result acquiring subunit is used for forming a pre-execution result set according to the at least two second pre-execution results and the first pre-execution result, and determining the pre-execution results which are the same in the pre-execution result set as pre-execution results to be counted;
the operation subunit is used for counting the number of the pre-execution results to be counted and taking the number of the pre-execution results to be counted as the counting number;
the quantity counting subunit is used for counting the total quantity of the results corresponding to the first pre-execution result and the at least two second pre-execution results;
a ratio determining subunit, configured to determine a quantity ratio between the operation quantity and the total quantity of results;
and the comparison result determining subunit is used for determining a comparison result between the first pre-execution result and the second pre-execution result according to the quantity ratio.
In one embodiment, the comparison result determining subunit is further specifically configured to compare the number ratio with a ratio threshold;
the comparison result determining subunit is further specifically configured to determine, if the number ratio is greater than the ratio threshold, a comparison result between the first pre-execution result and the second pre-execution result as a matching result;
the comparison result determining subunit is further specifically configured to determine, if the number ratio is smaller than the ratio threshold, a comparison result between the first pre-execution result and the second pre-execution result as a mismatch result.
In one embodiment, the factor consensus unit comprises:
the first factor consensus subunit is used for performing consensus on the primary key values to obtain first factor consensus sub-results corresponding to the primary key values;
the second factor consensus subunit is used for performing consensus on the foreign key values to obtain second factor consensus sub-results corresponding to the foreign key values;
the third factor consensus subunit is used for performing consensus on the data types to obtain third factor consensus sub-results corresponding to the data types;
and the consensus result determining subunit is used for determining the factor consensus result corresponding to the primary key value, the foreign key value and the data type together according to the first factor consensus sub-result, the second factor consensus sub-result and the third factor consensus sub-result.
In one embodiment, the data integrity constraint rules include uniqueness constraint rules configured for primary key values;
the first factor common-identification subunit is further specifically configured to acquire a target entity object indicated by the primary key value;
the first factor consensus subunit is further specifically used for traversing the stored entity object set contained in the relational database based on the uniqueness constraint rule;
the first factor consensus subunit is further specifically configured to determine, if a stored entity object identical to the target entity object does not exist in the stored entity object set, the target entity object as a unique entity object, and determine a first factor consensus sub-result corresponding to the primary key value as a factor consensus passing result;
the first factor consensus subunit is further specifically configured to, if a stored entity object that is the same as the target entity object exists in the stored entity object set, determine the target entity object as a duplicate entity object, and determine a first factor consensus sub-result corresponding to the primary key value as a factor consensus failure result.
In one embodiment, the data integrity constraint rules include a reference validity constraint rule configured for foreign key values;
the second factor consensus subunit is further specifically configured to determine, in the structured query language instruction, a reference object indicated by the foreign key value and an object file to which the reference object belongs, based on the reference validity constraint rule;
the second factor consensus subunit is also specifically used for acquiring the object file and traversing the object file;
the second factor consensus subunit is further specifically configured to, if the object file includes the reference object, determine the reference object as the valid reference object, and determine a second factor consensus sub-result corresponding to the foreign key value as a factor consensus passing result;
the second factor consensus subunit is further specifically configured to, if the reference object is not included in the object file, determine the reference object as an invalid reference object, and determine the second factor consensus sub-result corresponding to the foreign key value as a factor consensus failure result.
In one embodiment, the data integrity constraint rule comprises a set of standard data types supported by a relational database;
the third factor consensus subunit is also specifically used for traversing the standard data type set;
the third factor consensus subunit is further specifically configured to determine the data type as an effective data type if a standard data type identical to the data type exists in the standard data type set, and determine a third factor consensus sub-result corresponding to the data type as a factor consensus passing result;
the third factor consensus subunit is further specifically configured to, if a standard data type that is the same as the data type does not exist in the standard data type set, determine the data type as an invalid data type, and determine a third factor consensus sub-result corresponding to the data type as a factor consensus failure result.
In an embodiment, the consensus result determining subunit is further specifically configured to determine, if the first factor consensus sub-result, the second factor consensus sub-result, and the third factor consensus sub-result are all factor consensus passing results, the factor consensus result corresponding to the primary key value, the foreign key value, and the data type together is determined as a consensus passing result;
the consensus result determining subunit is further specifically configured to determine, if at least one of the first factor consensus sub-result, the second factor consensus sub-result, and the third factor consensus sub-result is a factor consensus failure result, the factor consensus result corresponding to the primary key value, the foreign key value, and the data type together is the consensus failure result.
In one embodiment, the uplink request carries a digital signature; the digital signature is obtained by the second node after the second node signs the block based on the private key of the second node;
the block-based data processing apparatus further comprises:
the signature verification module is used for acquiring a public key of the second node and verifying the signature of the digital signature based on the public key;
the step execution module is used for executing a step of acquiring a first pre-execution result of the transaction data in the block based on the uplink request if the signature verification passes, and commonly identifying the block according to the first pre-execution result and a data integrity constraint rule indicated by the relational data model to obtain a commonly identified result of the block;
and the communication suspension module is used for marking the second node as an abnormal node if the verification and the signature fail to pass, and suspending the data communication with the abnormal node in a target time period.
An aspect of an embodiment of the present application provides a computer device, including: a processor and a memory;
the memory stores a computer program that, when executed by the processor, causes the processor to perform the method in the embodiments of the present application.
An aspect of the embodiments of the present application provides a computer-readable storage medium, in which a computer program is stored, where the computer program includes program instructions, and the program instructions, when executed by a processor, perform the method in the embodiments of the present application.
In one aspect of the present application, a computer program product is provided, the computer program product comprising a computer program stored in a computer readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the method provided by the aspect of the embodiment of the present application.
In the embodiment of the present application, when a first node receives a uplink request for a block sent by a certain node (e.g., a second node), pre-execution is performed on transaction association operations in transaction data based on a structured query language instruction of the transaction data in the block to obtain an execution result (which may be referred to as a first pre-execution result), then the block is identified based on the first pre-execution result and a data integrity constraint rule indicated by a relational data model, and when the identification result of the block is an identification passing result, the block is stored in a relational database (a database established based on the relational data model) corresponding to the block chain. It should be understood that the present application uses a relational database to store the data on the block chain, and uses a structured language query instruction to access the relational database, so that the present application can perform the relational operation on the transaction data through the structured language query instruction. Because the relational data model can intuitively and flexibly store and access the structured instructions, the complicated incidence relation among the business data can be intuitively and accurately presented through simple instructions, the relational operation can be flexibly and accurately carried out on the transaction data in the application through the structured query language instructions, excessive manpower and time are not needed, the flexibility and the accuracy of the relational operation of the transaction data can be well improved, and the data processing efficiency and the accuracy are further improved; meanwhile, the data integrity constraint of the relational data model can be added in the block chain consensus process, namely the consensus process can not only perform consensus based on the execution result of the transaction data, but also perform consensus based on the data integrity constraint rule, so that the data written into the relational database can be ensured to be in accordance with the data integrity constraint rule, and the accuracy of the written data can be further improved. In conclusion, the method and the device can improve the flexibility of relation operation of the service data in the block chain service, further improve the data processing efficiency and accuracy, and simultaneously reduce the data processing cost.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a system architecture diagram according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a data processing method based on a block chain according to an embodiment of the present application;
fig. 3 is a schematic flowchart illustrating a process of consensus on blocks based on data integrity constraint rules according to an embodiment of the present application;
FIG. 4 is a diagram of a system logic architecture provided by an embodiment of the present application;
FIG. 5 is a flow chart of a system provided by an embodiment of the present application;
fig. 6 is a schematic structural diagram of a data processing apparatus according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The data processing method based on the block chain can be applied to a block chain network. The blockchain network comprises a network formed by related nodes for recording and inquiring data blocks on the blockchain, wherein each node in the blockchain network is a blockchain node and is computer equipment capable of inquiring or recording the data blocks. Since the solution provided by the embodiments of the present application relates to a blockchain and other related technologies, for ease of understanding, the following description will give priority to the blockchain and related concepts of the blockchain.
1. Block chains: in a narrow sense, a block chain is a chain data structure taking a block as a basic unit, and the transaction history acquired before is verified by using a digital abstract in the block, so that the block chain is suitable for the requirements of tamper resistance and expandability in a distributed accounting scene; in a broad sense, blockchain also refers to distributed accounting techniques implemented by blockchain architecture, including distributed consensus, privacy and security protection, peer-to-peer communication techniques, network protocols, intelligent contracts, and the like. The goal of the blockchain is to implement a distributed data record ledger that allows only additions and not deletions. The basic structure of the ledger bottom layer is a linear linked list. The linked list is composed of a series of 'blocks', the Hash (Hash) value of the previous block is recorded in the subsequent block, and whether each block (and the transaction in the block) is legal or not can be quickly checked by calculating the Hash value. If a node in the network proposes to add a new block, a consensus has to be established for the block via a consensus mechanism.
It should be understood that the blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm, and is mainly used for sorting data in time sequence and encrypting the data into an account book, so that the data cannot be tampered and forged, and meanwhile, the data can be verified, stored, and updated. The blockchain is essentially a decentralized database, each node in the database stores an identical blockchain, and the blockchain network divides the nodes into core nodes, data nodes and light nodes, wherein the core nodes are responsible for the consensus of the whole blockchain network, that is, the core nodes are the consensus nodes in the blockchain network. The process of writing the transaction data into the account book in the blockchain network can be that the client sends the transaction data to the data node or the light node, then the transaction data is transmitted between the data node or the light node in the blockchain network in a baton mode until the consensus node receives the transaction data, the consensus node packs the transaction data into a block and performs consensus with other consensus nodes, and after the consensus passes, the block carrying the transaction data is written into the account book.
It is to be understood that the blockchain system may include an intelligent contract, and the intelligent contract may be understood in the blockchain system as a code that each node (including a common node) of the blockchain can understand and execute, and may execute any logic and obtain a result. The user can invoke the intelligent contract already deployed on the blockchain by initiating a transaction service request through the client, and then the data node or the light node on the blockchain can send the transaction service request to the consensus node, and each consensus node on the blockchain can respectively run the intelligent contract. It should be understood that one or more intelligent contracts may be included in the blockchain, and these intelligent contracts may be distinguished by identification numbers (IDs) or names, and the client-initiated transaction service request may also carry the identification numbers or names of the intelligent contracts, so as to specify the intelligent contracts that the blockchain needs to run. If the intelligent contract specified by the client is a contract needing to read data, each consensus node accesses the local account book to read the data, and finally, each consensus node mutually verifies whether the execution results are consistent (namely, performs consensus), and if so, the execution results can be stored in the respective local account books and returned to the client.
2. Block chain node: the blockchain network distinguishes nodes as consensus nodes (which may also be referred to as core nodes) and synchronization nodes (which may include data nodes and light nodes). The consensus node is responsible for the consensus service of the whole block chain network; the synchronization node is responsible for synchronizing the book information of the consensus node, namely synchronizing the latest block data. Whether the node is a consensus node or a synchronization node, the internal structure of the node comprises network communication components, because the blockchain network is essentially a Peer-to-Peer (P2P) network and needs to communicate with other nodes in the blockchain network through the P2P components. Resources and services in the block chain network are distributed on each node, and information transmission and service realization are directly carried out among the nodes without intervention of an intermediate link or a centralized server (a third party).
3. Public key (public key) and private key (private key): the public key and the private key are a key pair (i.e. a public key and a private key) obtained through an algorithm, the public key is a public part of the key pair, and the private key is a non-public part. Public keys are typically used to encrypt data, verify digital signatures, and the like. By means of this algorithm it is ensured that the resulting key pair is unique, and that when using this key pair, if one of the keys is used to encrypt a piece of data, the other key must be used to decrypt it, e.g. if the data is encrypted with the public key, the private key must be used to decrypt it, and if the data is encrypted with the private key, the public key must be used to decrypt it, otherwise the decryption will not succeed.
4. And (3) hash value: also called information characteristic value or characteristic value, a hash value is generated by converting input data of an arbitrary length into a password by a hash algorithm and fixedly outputting, and original input data cannot be retrieved by decrypting the hash value, which is a one-way encryption function. In a blockchain, each block (except the original block) contains the hash value of the succeeding block, which is referred to as the parent block of the current block. Hash values are the core foundation and most important aspect of the potential in blockchain technology, which preserves the authenticity of the record and view data, as well as the integrity of the blockchain as a whole.
5. Smart Contract (Smart Contract): is a computer protocol intended to propagate, validate or execute contracts in an informational manner. In a blockchain system, an intelligent contract (contract for short) is a code that can be understood and executed by each node of the blockchain, and can execute any logic and obtain a result. In practical applications, intelligent contracts are managed and tried through transactions on blockchains. Each transaction corresponds to a Remote Procedure Call (RPC) request to the blockchain system. If the intelligent contract is said to correspond to an executable program, the blockchain corresponds to the operating system that provides the runtime environment. A blockchain may contain a plurality of contracts, distinguished by contract account number (ID), identification number, or name. For example, the intelligent contract may include a governance consensus committee contract, which is mainly used for managing consensus nodes, and may include recording node states of the consensus nodes, dynamically adding the consensus nodes, removing abnormal consensus nodes, and the like.
6. The wallet is used for providing functions of conducting transactions of digital assets, including initiating transactions (namely, sending transaction records of current transactions to other nodes in the blockchain system, and storing record data of the transactions into a temporary block of the blockchain as a response for confirming that the transactions are valid after the other nodes are successfully verified), and of course, the wallet also supports inquiry of the digital assets (or called digital resources) remaining in digital asset addresses (also called digital resource addresses).
Referring to fig. 1, fig. 1 is a schematic diagram of a system architecture according to an embodiment of the present disclosure. As shown in fig. 1, the system may include a blockchain network 100a, an application server 100b, and a cluster of terminal devices. The block chain network 100a may include: the blockchain node 10a, the blockchain point 10b, the blockchain point 10c, and the blockchain node 10d, it is understood that the blockchain network 100a may include one or more blockchain nodes, and the number of blockchain nodes is not limited in the embodiment of the present application. It is understood that in the blockchain network 100a, the blockchain link points 10a, 10b, 10d can perform data interaction through the network connection with the blockchain link point 10 c. It should be appreciated that each blockchain node (e.g., blockchain node 10a, blockchain point 10b, blockchain point 10c, blockchain point 10d) in the blockchain network 100a may be used To maintain the same blockchain (e.g., blockchain 10e shown in fig. 1), and any two blockchain nodes in the blockchain network 100a may form a point-To-point (P2P, Peer To Peer) network therebetween, and the point-To-point network may employ a P2P Protocol, where the P2P Protocol is an application layer Protocol operating on a Transmission Control Protocol (TCP). In a distributed system, any device, such as a server, a terminal device, etc., may join to become a blockchain node.
It can be understood that, as shown in fig. 1, a block link point 10a, a block link point 10b, a block link point 10c, a block link node 10d, and the like may respectively have a one-to-one correspondence relationship with corresponding roles (i.e., entity objects under corresponding service scenarios) that need to be accessed to the block link network 100 a. The service scenario herein may specifically include an electronic bill scenario, a social scenario, a resource release scenario, a payment scenario, and the like. At this time, the service data information in the corresponding service scene may specifically include electronic ticket information in an electronic ticket scene, data interaction information in a social scene, resource release information in a resource release scene, asset transition records in a payment scene, and the like, and specific contents of the service data information in the corresponding service scene are not listed one by one here.
It will be appreciated that the system described above may include one or more application servers, and the number of application servers will not be limited herein; application server 100b, as shown in fig. 1, may be networked with blockchain network 100a to enable data interaction over the network connection with blockchain network 100 a. The application server 100b may be a background server corresponding to an application having a business function of processing data associated with the data in the blockchain network 100 a.
The terminal device cluster may include a terminal device 100c, a terminal device 100d, terminal devices 100e, …, and a terminal device 100f, and it may be understood that the terminal device cluster may include one or more terminal devices, and the number of the terminal devices is not limited in this embodiment of the application. There may be network connection between the terminal clusters, for example, there may be network connection between the terminal device 100c and the terminal device 100 d. Meanwhile, any terminal device in the terminal cluster may have a network connection with the application server 100b, for example, a network connection exists between the terminal device 100f and the application server 100 b. Meanwhile, any terminal device in the terminal cluster may have a network connection with the blockchain network 100a, for example, a network connection exists between the terminal device 100d and the blockchain network 100 a. Meanwhile, any terminal device in the terminal cluster may have a network connection with the storage device 200a, for example, a network connection exists between the terminal device 100f and the storage device 200 a. The network connection is not limited to a connection manner, and may be directly or indirectly connected through a wired network manner, may be directly or indirectly connected through a wireless network manner, and may also be connected through other manners, which is not limited herein.
It should be understood that each terminal device in the terminal cluster shown in fig. 1 may be installed with an application client (also referred to as a target application), the application server 100b may not be a background server corresponding to the application client, and when the application client runs in each terminal device, data interaction, that is, the above-mentioned network connection, may be performed between the application client and the application server 100b shown in fig. 1, respectively. The application client (target application) may be an application client having a data processing function, such as a video application, a live broadcast application, a social application, an instant messaging application, a game application, a music application, a shopping application, a novel application, a browser, a digital asset application, and a digital resource application, and the application client may further have a function of processing a digital asset. The application client may be an independent client, or may be an embedded sub-client integrated in a certain client (for example, a social client, an educational client, a multimedia client, and the like), which is not limited herein. Taking the target application as the social application as an example, the application server 100b may be a set including a plurality of servers such as a background server and a data processing server corresponding to the social application, so that each terminal device may perform data transmission with the application server 100b through an application client corresponding to the social application, for example, each terminal device may upload an issuing request of service data to the application server 100b through the application client of the social application, and then the application server 100b may issue the issuing request of the service data to other terminal devices or transmit the issuing request of the service data to the block chain network 100 a.
It is understood that in the embodiments of the present application, related data such as user information is referred to, when the embodiments of the present application are applied to specific products or technologies, user permission or consent needs to be obtained, and the collection, use and processing of related data need to comply with relevant laws and regulations and standards of relevant countries and regions.
For convenience of subsequent understanding and description, in the embodiment of the present application, one terminal device may be selected as a target terminal device in the terminal cluster shown in fig. 1, for example, the terminal device 100c is taken as the target terminal device. The target terminal device can send transaction data to the data node or the light node, then the transaction data is transmitted between the data node or the light node in the block chain network in a baton mode until the transaction data is received by the consensus node, the consensus node packs the transaction data into a block and performs consensus with other consensus nodes, and after the consensus passes, the block carrying the transaction data is written into an account book.
In order to improve the applicability of a blockchain to a service scene and enable the blockchain to better describe the incidence relation between different service data in different service scenes, the application provides a data processing method for storing the data on the chain based on a relational database (a database established based on a relational data model), and as the relational data model has a more flexible data operation mode and a more rigorous data integrity constraint rule, after the relational database corresponding to the relational data model is adopted, a user can customize a relational data structure, relational operation, data constraint conditions and the like in an intelligent contract, so that the contract development work efficiency can be well improved; meanwhile, because the relational data model supports Structured information, through a flexible data operation mode of the relational data model, a user can perform more flexible relational operation on data through Structured Query Language (SQL) statements in an intelligent contract, so that the operation flow can be simplified, and the data processing efficiency can be improved. In order to improve the rigor of data processing to improve the accuracy, the data integrity constraint rule of the relational data model can be introduced into the consensus process of the block chain, that is, when the consensus nodes in the application perform consensus on the blocks, the data integrity constraint based on the relational data model is additionally required to perform consensus on the blocks.
For the sake of understanding, taking an example that a certain common node (e.g. a first node) receives a uplink request from another common node (e.g. a second node) for a certain block, the second node desires to share the block with the first node and stores the block in a block chain maintained by the first node and the second node after the sharing is passed. Since the relational database is used to store the on-chain data of the block chain, storing the block into the block chain may refer to storing the data in the block into the relational database corresponding to the block chain. In this application, the first node may invoke an intelligent contract corresponding to the transaction data based on the uplink request, and perform pre-execution on each transaction data in the block through the intelligent contract to obtain a pre-execution result. It should be understood that, since the relational operations in the present application can all be operated through SQL statements, pre-executing the transaction data can be structured query language commands (SQL commands, which may also be referred to as structured query language commands) generated for executing all transaction data in the block, and it can be understood that each structured query language command can correspond to one logic step, and when all the structured query language commands related to one transaction data are executed, that is, the execution logic corresponding to the transaction data is executed, the obtained command execution result can be the execution result of the transaction data. That is, when the structured query language instruction is executed, that is, the corresponding logic operation (which may be referred to as a transaction related operation) related to the transaction data is executed, an instruction execution result is obtained when the structured query language instruction indicated by all the logic operations is executed, and the instruction execution result is a pre-execution result of the corresponding transaction data (the pre-execution result obtained by the first node may be referred to as a first pre-execution result).
Similarly, the second node may also obtain a pre-execution result (the pre-execution result obtained by the second node may be referred to as a second pre-execution result). The first node may perform consensus on the block based on the first pre-execution result, the second pre-execution result, and the data integrity constraint rule indicated by the relational data model, so as to obtain a consensus result of the block. When the consensus result of the block is a consensus pass result, the block can be stored in the relational database. For a specific implementation manner in which the first node performs consensus on the block based on the first pre-execution result, the second pre-execution result, and the data integrity constraint rule indicated by the relational data model to obtain the consensus result of the block, reference may be made to the description in the embodiment corresponding to fig. 2.
As can be seen from the above, the method provided in the embodiments of the present application may be executed by a computer device, which includes, but is not limited to, a terminal device, an application server, or a blockchain node. The application server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as cloud service, a cloud database, cloud computing, a cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN, big data and artificial intelligence platform. The terminal device may include: the smart terminal may be a smart terminal that carries a multimedia data processing function (e.g., a video data playing function, a music data playing function), such as a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart television, a smart speaker, a desktop computer, a smart watch, and a vehicle-mounted device, but is not limited thereto.
It can be understood that the application server 100b, the terminal device 100c, the terminal device 100d, the terminal device 100e, and the terminal device 100f may all be block link points in the block chain network 100a, data (e.g., transaction data) described in full text may be stored, and the storage manner may be a manner in which the block link points generate blocks according to the data, and add the blocks to the block chain for storage. In a distributed system such as a blockchain, any form of computer device, such as an application server, an electronic device such as a terminal device, etc., may become a node in the blockchain system by joining the peer-to-peer network.
Further, please refer to fig. 2, wherein fig. 2 is a schematic flowchart of a data processing method based on a block chain according to an embodiment of the present application. The embodiment of the application can be applied to various scenes, including but not limited to cloud technology, artificial intelligence, intelligent traffic, driving assistance and the like. The data processing method based on the blockchain may be executed by a computer device, where the computer device may refer to an application server (e.g., the application server in the embodiment corresponding to fig. 1), may also refer to a terminal device (e.g., any terminal device in a terminal device cluster in the embodiment corresponding to fig. 1), and may also refer to a device integrated with the application server and the terminal device. As shown in fig. 2, the flow of the data processing method based on the block chain may include at least the following steps S101 to S103:
step S101, a first node receives an uplink request aiming at a block sent by a second node; the uplink request is used for requesting to store the block into a relational database corresponding to the block chain, and the relational database refers to a database established based on a relational data model.
In this application, the first node and the second node may both be nodes in a block chain, and for example, the first node and the second node may both be core nodes (also referred to as consensus nodes) in the block chain, the core nodes may receive transaction data sent from a data node or a light node in the block chain, and the transaction data may be sent to the data node or the light node by the terminal device. The transaction data may be data generated by the terminal device according to a transaction service initiated by the user, and after obtaining user authorization, the terminal device may send the transaction data to the data node or the light node. After the core node receives the transaction data sent by different data nodes, the received transaction data can be temporarily cached in the transaction pool, and after the core node receives the transaction data sent by the data nodes within a period of time, one or more transaction data can be obtained from the transaction pool, and a block is generated according to the transaction data. If the node generating the block desires to store the block into the blockchain, the node needs to initiate a consensus request for the block to a consensus node in the blockchain, and the consensus node of the blockchain can perform consensus on the block together based on the consensus request, and after the block passes the consensus, the block can be stored into the blockchain. Wherein, since the node is a consensus request initiated to expect the block to be stored in the blockchain, the consensus request may also be referred to as an uplink request.
It should be understood that the present application may build a relational database based on the relational data model and employ the relational database to store the on-chain data of the blockchain. That is, if it is desired to store a chunk into a blockchain, it may refer to storing the chunk into a relational database corresponding to the blockchain. For the convenience of understanding the relational data model and the relational database, the relational data model and the relational database will be described in detail below. The relational data model refers to a data model for representing entities and relations between the entities in the form of a two-dimensional table, and is a model for representing the entities and relations between the entities in the form of a two-dimensional table in a database of a relational structure, that is, the relational data model mainly adopts a table to express relations between data and data. For example, to express a many-to-many relationship between entity a and entity b, three tables may be created, two for expressing entities a and b, respectively, and a third table may be used for expressing the relationship between entity a and entity b. In the relational data model, real-world entities and various connections between entities are represented by relationships.
The relational database system is a database system supporting the relational data model, is established based on the relational data model, is a database with a relational structure, and can be also called a relational database. Relational databases mainly use a relational data model to organize data, which stores data in the form of rows and columns for users to understand, a series of rows and columns of the relational database are called tables, a group of tables form the database, and the relational database is mainly used for transaction processing and mainly comprises databases such as Oracle, DB2, MySQL, Microsoft SQL Server, Microsoft Access and the like.
It can be understood that the corresponding relational database and the relational database mainly support Structured information, that is, the operations such as adding, deleting, modifying and the like of the relational database can be realized by accessing the relational database through a Structured Language, and the Structured Language can include a Structured Query Language (SQL). Then, in the present application, a user may customize a structured data storage manner in the intelligent contract of the blockchain, so that the relational database may be accessed based on a structured query language statement (such as an SQL statement) to store data of the blockchain based on the relational data model. For example, a table structure of a relational database may be defined at the time of installing an intelligent contract based on the SQL syntax, which may be implemented mainly as follows: in the initialization method of the intelligent contract, an Application Programming Interface (API) provided by the intelligent contract is called to execute the table building SQL. Of course, the specific implementation manner of defining the table structure of the relational database when the intelligent contract is installed is not limited to the above implementation manner, and may also be any other manner capable of defining the table structure of the relational database in the intelligent contract, for example, the specific implementation manner may also be: in the installation package of the intelligent contract, the SQL command for creating the table is written into a specific file or a specific file directory, so that the table structure of the relational database can be defined in the intelligent contract. After the table structure of the relational database is defined and completed in the corresponding intelligent contract, the corresponding intelligent contract can be adopted to process the transaction data in the block, when the transaction data is processed based on the corresponding intelligent contract, the SQL command related to the transaction data can be executed in the intelligent contract, the relational database can be accessed by executing the SQL command, and the increase, deletion, modification and check of the relational database are realized. The SQL command related to the transaction data can be written by a user (instruction writing object); the user may also deploy a corresponding program (such as a program template or a program function, for example, the user may customize a structured data storage in the intelligent contract, so that the intelligent contract may support the user to perform a relational operation on the data through a structured query language command, for example, perform operations of adding, deleting, modifying, checking, etc. on the data, and when the intelligent contract is invoked, the intelligent contract may determine a corresponding SQL command according to a logical operation involved in the transaction data and the program deployed in the contract.
Step S102, acquiring a first pre-execution result of transaction data in a block based on the uplink request, and performing consensus on the block according to the first pre-execution result and a data integrity constraint rule indicated by the relational data model to obtain a consensus result of the block; the first pre-execution result is an execution result obtained after the first node pre-executes the transaction associated operation related to the transaction data based on the structured query language instruction corresponding to the transaction data; the structured query language instructions refer to instructions that operate on the relational database to perform transaction-related operations.
In this application, the first pre-execution result may refer to an execution result obtained after the first node pre-executes the transaction data in the block. It should be understood that, since the present application uses the relational database to store the on-chain data of the block chain, and the relational database is also mainly accessed by using the structured information (e.g. structured query language), the process of pre-executing the transaction data in the block for pre-executing the first node may also be pre-executed by using the structured query language command, for example, after receiving the uplink request, the first node may invoke a corresponding intelligent contract according to the content of the transaction data, where the intelligent contract is defined with a table structure of the relational database, and all the structured query language commands (also referred to as structured query language commands, such as SQL commands) related to the transaction data may be executed by using the intelligent contract, for the process of executing the structured query language commands, that is, the process of executing the transaction data, for the execution result of the structured query language commands, or as a result of execution of the transaction data (i.e., pre-execution).
It should be understood that, for a transaction service (transaction data), it can be divided into different transaction logic operation steps, and one transaction logic operation step can correspond to one structured query language instruction (such as SQL command), and of course, one transaction logic operation step can also correspond to a plurality of different structured query language instructions (that is, executing one transaction logic operation step requires executing a plurality of structured query language instructions). When executing the structured query language instructions, the corresponding structured query language instructions may be executed in sequence according to the execution sequence of the transaction logic operation steps, and one structured query language instruction may correspond to one instruction execution result (whether the execution is successful or not), and when all the structured query language instructions related to one transaction service are successfully executed and the instruction execution results of all the structured query language instructions are successfully executed, the final instruction execution result of the structured query language instructions related to the transaction service may be considered as a successful execution result (which may also be referred to as a normal execution result); correspondingly, if one or more structured query language instructions in all the structured query language instructions related to one transaction service cannot be successfully executed, the instruction execution result of the structured query language instruction is an execution failure result, and at this time, the final instruction execution result of the structured query language instruction related to the transaction service can be considered as an execution failure result (also referred to as an abnormal execution result).
It should be understood that, since all transaction logic operation steps related to one transaction data have a certain relevance, for example, all transaction logic operation steps related to one transaction data include transaction logic operation step 1, transaction logic operation step 2 and transaction logic operation step 3, transaction logic operation step 2 must depend on the execution result of transaction logic operation step 1 to be executed, and transaction logic operation step 3 must depend on the execution result of transaction logic operation step 2 to be executed, there is a dependency execution relationship among transaction logic operation step 1, transaction logic operation step 2 and transaction logic operation step 3. Accordingly, the present application refers to the transaction logic operation step as a transaction association operation according to this association of transaction logic operation steps, that is, one transaction data may relate to a plurality of transaction association operations. For ease of understanding, a user a initiates a transfer transaction service (the user a transfers 5000 units to the user b, which may refer to one transaction data) through the user terminal 100c, and the user a may select an intelligent contract in the block chain (for example, select an intelligent contract a having transfer transaction logic and containing a relationship data structure) through the user terminal 100c, that is, the user a may select an intelligent contract in the block chain for performing the transfer transaction service. It should be appreciated that the execution logic for the transfer transaction service for the intelligent contract may be the following 5 steps:
1. the balance of user a is read in the blockchain.
2. The balance of subscriber b is read in the blockchain.
3. And making a logic judgment of transfer, and modifying the balance of the user a and the user b.
4. The latest balance of user a is written into the blockchain.
5. The latest balance of user b is written into the blockchain.
Each step can be understood as a transaction related operation, and the transaction related operations designed for the transfer transaction service (transfer transaction data) include 5 transaction related operations, each transaction related operation may be a structured query language instruction, and the structured query language instruction corresponding to each transaction related operation may be a structured query language instruction related to the transaction data, and the structured query language instruction indicated by one transaction related operation may be executed for the structured query language instruction related to the transaction data, so as to obtain an instruction execution result (here, in order to distinguish from final instruction execution results of all instructions, an instruction execution result of one structured query language instruction may be referred to as an instruction execution sub-result). For example, taking the transaction association operation 1 as an example, for the transaction association operation of reading the balance of the user a in the blockchain, a structured query language instruction (e.g., a structured query language instruction P) may be corresponding to the transaction association operation, and the structured query language instruction may be used to operate the relational database, so as to query the corresponding balance (embodied as a numerical value in the relational database) under the account address of the user a in the relational database. And a value may be returned based on the relational database, which is the balance of the user a. Of course, if the relational database successfully returns the balance of the user a, the instruction execution sub-result of the structured query language instruction P may be a successful execution result; if the instruction cannot be executed, which results in the database being inaccessible (e.g., instruction format is incorrect or other exception reason), the sub-result of the instruction execution of the structured query language instruction P may be an abnormal execution result. It should be understood that, when all the instruction execution sub-results of all the structured query language instructions involved in one transaction data are successful execution results, the execution result (for example, the first pre-execution result) of the transaction data may be regarded as a successful execution result if the final instruction execution result corresponding to all the structured query language instructions is a successful execution result, and when there is an abnormal execution result if there is an instruction execution sub-result of a certain structured query language instruction in all the structured query language instructions involved in the transaction data, the final instruction execution result corresponding to all the structured query language instructions may be regarded as an abnormal execution result if the final instruction execution result (for example, the first pre-execution result) is an abnormal execution result if the final instruction execution result corresponding to all the structured query language instructions is an abnormal execution result if the final instruction execution result is an abnormal execution result.
It can be understood that, since the relational database is mainly used for transaction processing, in order to respond to the relational database, the first node in the present application may open a database transaction after receiving a uplink request for a block, and all structured query language instructions (such as SQL commands) related to transaction data in the current block may be executed in the database transaction to obtain a first pre-execution result of the transaction data. That is, the specific implementation of the first pre-execution result for the transaction data in the uplink request acquisition block may be as follows: an initial database transaction for a block may be created based on the uplink request; in the initial database transaction, a structured query language instruction indicated by transaction association operation can be executed to obtain an instruction execution result; subsequently, the instruction execution result may be determined as a first pre-execution result of the transactional data. The instruction execution result herein may refer to a final instruction execution result of all the structured query language instructions of one transaction data, that is, the final instruction execution result of all the structured query language instructions related to one transaction data may be a pre-execution result (e.g., a first pre-execution result) of the transaction data.
As can be seen from the above description, for each common node (including the first node and the second node) in the blockchain, the transaction association operation related to the transaction data may be executed based on the structured query language instruction corresponding to the transaction data, so that the pre-execution result corresponding to the transaction data may be obtained. For a certain consensus node, the block to which the transaction data belongs can be consensus based on the pre-execution result of the consensus node and the pre-execution results of other consensus nodes, and after the consensus passes, the block can be stored in the block chain. Taking the first node and the second node as an example, the method may refer to an execution result obtained after the first node performs pre-execution on the transaction related operation related to the transaction data based on the structured query language instruction corresponding to the transaction data as a first pre-execution result, and refer to an execution result obtained after the second node performs pre-execution on the transaction related operation related to the transaction data based on the structured query language instruction corresponding to the transaction data as a second pre-execution result, where the uplink request sent by the second node to the first node may carry the second pre-execution result, and then the first node may perform common identification on the block based on the first pre-execution result, the second pre-execution result, and a data integrity constraint rule indicated by the relationship data model.
From the foregoing, it should be understood that, for the consensus on the blocks according to the first pre-execution result and the data integrity constraint rule indicated by the relational data model, a specific implementation manner of obtaining the consensus result of the blocks may be: the first pre-execution result and the second pre-execution result can be compared to obtain a comparison result; if the comparison result between the first pre-execution result and the second pre-execution result is a matching result, acquiring a primary key value contained by the structured query language instruction, an external key value contained by the structured query language instruction and a data type corresponding to the structured query language instruction based on a data integrity constraint rule indicated by the relational data model, then performing consensus on the primary key value, the external key value and the data type to obtain a factor consensus result corresponding to the primary key value, the external key value and the data type, and then determining the factor consensus result as a block consensus result; if the comparison result between the first pre-execution result and the second pre-execution result is a mismatch result, the common identification result of the block can be regarded as a common identification failure result.
It should be understood that each common node may compare and verify the pre-execution result obtained by itself with the pre-execution results of other common nodes, in an actual scene, there are at least two (generally more than two) common nodes, a cluster formed by each common node may be referred to as a common node cluster, when the pre-execution results of the common nodes in a certain proportion in the common node cluster are the same result, it may be considered that the comparison and verification of the pre-execution results are verification passing results (the pre-execution results are matchable), then at this time, the next step may be performed, and the block is again commonly identified based on the data integrity constraint rule; if the comparison of the pre-execution results is verified as a verification failure result (the pre-execution results cannot match), the consensus result of the blocks can be directly determined as the consensus failure result.
For convenience of understanding, taking the number of the second nodes as at least two as an example, since one second node can obtain one pre-execution result (second pre-execution result), each of the at least two second nodes can pre-execute the transaction-related operation related to the transaction data based on the structured query language instruction corresponding to the transaction data to obtain one second pre-execution result, that is, the number of the second pre-execution results is also at least two; taking the number of the second nodes as at least two and the number of the second pre-execution results as at least two as an example, the specific implementation manner of comparing the first pre-execution result with the second pre-execution result to obtain the comparison result may be: a pre-execution result set can be formed according to the at least two second pre-execution results and the first pre-execution result, and then the pre-execution results which are the same in the pre-execution result set can be determined as the pre-execution results to be counted; then, the number of the pre-execution results to be counted can be counted, and the number of the pre-execution results to be counted is used as the counting number; meanwhile, the total number of results corresponding to the first pre-execution result and the at least two second pre-execution results can be counted; subsequently, a quantity ratio between the number of operations and the total number of results may be determined, and a comparison result between the first pre-execution result and the second pre-execution result may be determined according to the quantity ratio.
The specific implementation manner of determining the comparison result between the first pre-execution result and the second pre-execution result according to the quantity ratio may be as follows: the quantity ratio may be compared to a ratio threshold; if the number ratio is greater than the ratio threshold, determining a comparison result between the first pre-execution result and the second pre-execution result as a matching result; if the number ratio is smaller than the ratio threshold, the comparison result between the first pre-execution result and the second pre-execution result may be determined as a mismatch result.
It can be understood that the first node may compare the first pre-execution result of the first node with at least two other second pre-execution results, and may form a pre-execution result set by the first pre-execution result and the at least two second pre-execution results, where each first pre-execution result and each second pre-execution result included in the pre-execution result set may be referred to as a pre-execution result; the pre-execution results that are the same in the set may be determined as the pre-execution results to be counted, and the number of the pre-execution results to be counted may be counted, which may be referred to as a statistical number. That is, the number of the same pre-execution results in the first pre-execution result and the at least two other second pre-execution results may be counted, if a ratio (such as the above number ratio) between the number of the same pre-execution results and the total number of results exceeds a ratio threshold (the threshold may be a preset value), it may be indicated that the execution results of the shared nodes in the shared node cluster exceeding the ratio are all the same, at this time, the pre-execution results may be considered to be successfully verified, in order to ensure that all honest nodes in the shared node cluster of the two blocks can obtain consistent results, improve the robustness of the block chain, further perform further consensus on the data integrity constraint rule based on the relational data model, for example, perform consensus on the main key value, the foreign key value, and the data type, to obtain a factor consensus result corresponding to the main key value, the foreign key value, and the data type together, the factor consensus result may then be determined as a consensus result for the block. For a specific implementation manner of obtaining a result of the common factor consensus based on the primary key value, the foreign key value, and the data type, the result of the common factor consensus corresponding to the primary key value, the foreign key value, and the data type may be described in an embodiment corresponding to fig. 3.
It should be noted that, in the block chain, in order to ensure the reliability and the authenticity of data transmission, the consensus node may perform authentication through the private key of the own party and the public key of the other party, and perform subsequent processing after the authentication is passed. For example, taking the example that the second node sends the uplink request for the block to the first node, the second node may sign the block based on a private key of the second node to obtain a digital signature, and send the uplink request carrying the digital signature to the first node, and the first node may check the digital signature based on a public key of the second node, and perform subsequent processing after the check passes. Taking as an example that the uplink request carries a digital signature, the digital signature is obtained by the second node after signing the block based on the private key of the second node, the specific implementation manner may be: the first node can acquire a public key of the second node, and the digital signature is verified based on the public key; if the check-out passes, performing subsequent processing, for example, acquiring a first pre-execution result of the transaction data in the block based on the uplink request, and performing consensus on the block according to the first pre-execution result and a data integrity constraint rule indicated by the relational data model to obtain a consensus result of the block; and if the verification and signing fails, the second node can be marked as an abnormal node, and data communication with the abnormal node is suspended in the target time period.
It should be understood that if the verification fails, the second node may be considered as an unreliable node (referred to as an abnormal node, e.g., a malicious node), and in this case, in order to ensure the security of data transmission, data communication with the abnormal node may be suspended for a certain time (e.g., a target time period).
In step S103, when the consensus result of the block is a consensus pass result, the block is stored in the relational database.
In the application, when the consensus result of the block is the consensus passing result, the block can be stored in the block chain. Specifically, as can be seen from the above description, when a structured language query instruction corresponding to transaction data is executed, a database transaction (such as the initial database transaction described above) may be created, and then the structured language query instruction is executed in the initial database transaction, so as to obtain an instruction execution result (as a first pre-execution result of the transaction data). Then, when the consensus result of the block is a consensus pass result, the application may submit the database transaction (including the structured query language instruction and the first pre-execution result, which may be referred to as a target database transaction) of the entire block, that is, may store the database transaction of the block in the relational database.
That is, the specific implementation for storing the blocks into the relational database may be: a target database transaction associated with the block may be obtained; the target database transaction comprises a structured query language instruction in transaction data and a first pre-execution result; storing the target database transaction in a relational database. The target database transaction may be understood as an initial database transaction that includes the structured query language instructions and the first pre-execution results.
Further, please refer to fig. 3, where fig. 3 is a schematic flow chart illustrating a process of identifying blocks based on a data integrity constraint rule according to an embodiment of the present application. The process may correspond to the process of identifying the primary key value, the foreign key value, and the data type in the embodiment corresponding to fig. 2, obtaining a factor identification result corresponding to the primary key value, the foreign key value, and the data type, and determining the factor identification result as the identification result of the block. The process may also be executed by a computer device, where the computer device may refer to an application server (e.g., the application server in the embodiment corresponding to fig. 1), may also refer to a terminal device (e.g., any terminal device in a terminal device cluster in the embodiment corresponding to fig. 1), and may also refer to a device in which the application server and the terminal device are integrated. As shown in fig. 3, the process may include at least the following steps S301 to S304:
step S301, performing consensus on the primary key values to obtain a first factor consensus sub-result corresponding to the primary key values.
Specifically, in order to improve data security, the relational data model specifies data integrity, which is used to constrain conditions that data in the relational database needs to satisfy, and therefore may also be referred to as a data integrity constraint rule. Data Integrity (Data Integrity) refers to the Accuracy (Accuracy) and Reliability (Reliability) of Data. It is proposed to prevent data which does not comply with semantic regulations from being present in the database and to prevent invalid operations or erroneous information from being caused by input and output of erroneous information. Data Integrity may include Entity Integrity (Entity Integrity), Domain Integrity (Domain Integrity), Referential Integrity (Referential Integrity), and User-defined Integrity (User-defined Integrity).
Wherein, the entity integrity refers to the integrity of the rows in the table. Mainly to ensure that the data (records) of the operation are non-empty, unique and non-repetitive. That is, entity integrity requires that there be one and only one primary key per relationship (table), each primary key value must be unique and must not be allowed to be "NULL" (NULL) or repeated. For example, if the attribute a is the main attribute of the basic relationship R, the attribute a cannot take a null value, i.e., the main attribute cannot be a null value. The NULL value (NULL) therein is not 0, nor a NULL or NULL string, but has no value. In practice, null values refer to values that are "not stored", "unknown" or "meaningless" temporarily. Since the primary key is the unique identifier of the entity data (record), if the primary attribute takes a NULL value, there will be unidentifiable (distinguishable) entity data (record) in the relationship, which contradicts the definition of the entity, and for the non-primary attribute, a NULL value (NULL) can be taken, so this rule is called an entity integrity rule. If there can not be null value in the main attribute "school number" (column) in the school address relation (table), otherwise, the data (record) in the school address table can not be called.
Domain integrity refers to the fact that a column in a database table must satisfy some particular data type or constraint. The constraint may include specifications such as a value range and accuracy. The CHECK, FOREIGN KEY constraints and DEFAULT, NOT NULL definitions in the table fall within the domain integrity category.
The Referential Integrity (Referential Integrity) belongs to the inter-table rule. For a permanent relational dependency table, when a record is updated, inserted or deleted, the integrity of the data is affected if only one is changed. For example, after deleting a record in the parent table, the corresponding record in the child table is not deleted, resulting in these records being referred to as orphaned records. The integrity of data between tables for updating, inserting or deleting is collectively referred to as referential integrity. Generally, there is a certain relation between entities in the objective reality, and both the entities and the relation between the entities in the relational data model are described in relation, so there may be relations and relations between them and references when operating.
In a relational database, the association between relationships is achieved through common attributes. This common attribute is often the primary key of one table while being the foreign key of another table. Reference is made in two respects to completeness: the relation between tables is realized, and the value of the foreign key must be the effective value of the primary key of another table or the value of 'null'. For example, if the property group F is the primary key of the relationship schema R1, and F is also the foreign key of the relationship schema R2, then in the relationship of R2, the value of F only allows two possibilities: null or equal to a primary key value in the R1 relationship. R1 is referred to as a "referenced relationship" mode, and R2 is referred to as a "referenced relationship" mode.
User-defined Integrity (User-defined Integrity), also known as domain Integrity rules, is a constraint on the properties of fields in a data table. Constraints including the value range of the field, the type of the field, and the validity rules (e.g., decimal places) of the field are determined by the attributes of the field defined when determining the relationship structure. For example, the value range of the percentage achievement is 0-100.
The method can be used for commonly identifying the blocks based on the data requirements respectively specified by the entity integrity, the domain integrity, the reference integrity and the user-defined integrity.
It should be understood that, since the entity integrity constraint rule is used to specify that the primary key value should have uniqueness, the entity integrity constraint rule may also be referred to as a uniqueness constraint rule, and based on the uniqueness constraint rule, the application may perform consensus on the structured query language instructions corresponding to the transaction data in the block, where, since the uniqueness constraint rule specifies that each row of the table is a unique entity in the table, when the structured query language instructions are verified to be consensus, the primary key value included in the structured query language instructions may be obtained, and if the structured query language instructions include the primary key value and a target entity object indicated by the primary key value is a unique entity, the structured query language instructions may be considered to satisfy the uniqueness constraint rule. If the structured query language instruction includes a primary key value but the target entity object indicated by the primary key value is not a unique entity, it can be determined that the structured query language instruction does not satisfy the uniqueness constraint rule.
It should be appreciated that the result of whether the structured query language instruction satisfies the uniqueness constraint rule can be considered a first factor consensus sub-result. For example, if the structured query language instruction satisfies the uniqueness constraint rule, the first factor consensus sub-result may be determined as a factor consensus passed result; if the structured query language instruction does not satisfy the uniqueness constraint rule, the first factor consensus sub-result may be determined as a factor consensus failure result (i.e., a factor consensus failed result).
That is to say, when the data integrity constraint rule includes a uniqueness constraint rule configured for the primary key value, the specific implementation manner of obtaining the first factor consensus sub-result corresponding to the primary key value by performing consensus on the primary key value may be as follows: acquiring a target entity object indicated by a primary key value; based on the uniqueness constraint rule, the stored entity object set contained in the relational database can be traversed; if the stored entity object identical to the target entity object does not exist in the stored entity object set, determining the target entity object as a unique entity object, and determining a first factor consensus sub-result corresponding to the primary key value as a factor consensus passing result; if the stored entity object identical to the target entity object exists in the stored entity object set, the target entity object may be determined as a duplicate entity object, and the first factor consensus sub-result corresponding to the primary key value is determined as a factor consensus failure result. Traversing a stored entity object set contained in a relational database, specifically, obtaining a table (which may be referred to as a target table) to which the primary key value belongs in the structured query language instruction from the relational database, traversing a row parameter indicated by the primary key value in the target table, querying whether a stored entity object identical to the target entity object exists in the row parameter, if so, determining the target entity object as a repeated entity object, and if so, indicating that the primary key value does not satisfy a uniqueness constraint rule, and determining a first factor common identifier sub-result corresponding to the primary key value as a factor common identifier failure result; if the primary key value does not exist, the target entity object can be determined as the unique entity object, at this time, it can be determined that the primary key value meets the uniqueness constraint rule, and then the first factor consensus sub-result corresponding to the primary key value can be determined as the factor consensus passing result.
Of course, traversing the set of stored entity objects contained in the relational database may also refer to traversing the stored entity objects contained in all tables in the relational database, if applicable. The traversal of all the tables in the relational database is more strict, and this traversal requires that each entity object in the relational database is a unique entity object, rather than that a certain entity object in a certain table is a unique entity object in the table.
Step S302, the foreign key value is identified in common, and a second factor identifying sub-result corresponding to the foreign key value is obtained.
Specifically, as can be seen from the above, the referential integrity realizes the relationship between tables, and the value of the foreign key must be the valid value of the primary key of another table, that is, the referential object indicated by the foreign key value needs to be a valid object (valid referential object) in another table. The referential integrity can also be referred to as referential validity constraint rules, when the data integrity constraint rules include referential validity constraint rules configured for foreign key values, based on the referential validity constraint rules, the application can perform consensus on the structured query language instructions corresponding to the transaction data in the block, wherein, because the referential validity constraint rules specify that the foreign key values need to be valid primary key values of another table, when the structured query language instructions are verified to be consensus, foreign key values contained in the structured query language instructions can be obtained, and if the structured query language instructions contain foreign key values and the reference objects indicated by the foreign key values are valid reference objects in a referred table, the structured query language instructions can be considered to satisfy the referential validity constraint rules. If the structured query language instruction includes a foreign key value, but the reference object indicated by the foreign key value is not a valid reference object, it can be determined that the structured query language instruction does not satisfy the reference validity constraint rule.
That is to say, when the data integrity constraint rule includes a reference validity constraint rule configured for the foreign key value, the specific implementation manner of obtaining the second factor consensus sub-result corresponding to the foreign key value by performing consensus on the foreign key value may be as follows: based on the reference validity constraint rule, a reference object indicated by the foreign key value and an object file to which the reference object belongs can be determined in the structured query language instruction; then, an object file can be obtained and traversed; if the object file contains the reference object, the reference object can be determined as an effective reference object, and a second factor consensus sub-result corresponding to the foreign key value is determined as a factor consensus passing result; if the target file does not contain the reference object, the reference object may be determined as an invalid reference object, and the second factor consensus sub-result corresponding to the foreign key value may be determined as a factor consensus failure result.
It is understood that the object file in the present application may refer to a table (which may be referred to as a referred table or a referred file) referred to by a foreign key, and in a relational database, an entity object written in each table needs to satisfy a certain constraint condition, so that when a certain entity object is written in a certain table, the certain entity object may be considered to be valid in the table. Then, when the reference object indicated by the foreign key value and the object file to which the reference object belongs are obtained, the object file may be traversed, and if the reference object is included in the object file (e.g., the reference object is an entity object in the object file), the reference object may be considered as an effective reference object, and at this time, it may be determined that the foreign key value satisfies the reference validity constraint rule, and then the second factor consensus sub-result corresponding to the foreign key value may be determined as a factor consensus passing result; if the reference object is not included in the target file (e.g., the reference object is not any physical object in the target file), the reference object may be considered as not being a valid reference object (i.e., an invalid reference object), and at this time, it may be determined that the foreign key value does not satisfy the reference validity constraint rule, and then the second factor consensus sub-result corresponding to the foreign key value may be determined as a factor consensus failure result.
Step S303, performing consensus on the data types to obtain a third factor consensus result corresponding to the data types.
Specifically, as can be seen from the above description, the domain integrity refers to that a column in a database table must satisfy a certain specific data type or constraint, and the domain integrity constraint rule may also be referred to as a type constraint rule, and if the data type constrained by the relational data model is referred to as a standard data type, the type constraint rule may include a standard data type set (which may be composed of one or more standard data types) that can be supported by the relational database. Based on the type constraint rule, the method can perform consensus on the structured query language instruction corresponding to the transaction data in the block, and for the structured query language instruction, a type description field which is included in the structured query language instruction and used for indicating a data type can be obtained; if the data type described by the type description field is any one of the standard data types specified by the non-relational data model, the structured query language instruction may be considered to not satisfy the integrity of the type, and at this time, the third factor consensus sub-result corresponding to the data type may be determined as the factor consensus failure result.
Step S304, determining a factor consensus result corresponding to the primary key value, the foreign key value and the data type according to the first factor consensus sub-result, the second factor consensus sub-result and the third factor consensus sub-result.
Specifically, after the factor consensus sub-results corresponding to the primary key value, the foreign key value, and the data type are determined, the factor consensus result corresponding to the primary key value, the foreign key value, and the data type may be determined based on the factor consensus sub-results corresponding to the primary key value, the foreign key value, and the data type. The specific mode can be as follows: if the first factor consensus sub-result, the second factor consensus sub-result and the third factor consensus sub-result are all factor consensus passing results, determining the factor consensus results corresponding to the primary key value, the foreign key value and the data type as consensus passing results; if at least one factor consensus sub-result among the first factor consensus sub-result, the second factor consensus sub-result, and the third factor consensus sub-result is a factor consensus failure result, the factor consensus result corresponding to the primary key value, the foreign key value, and the data type may be determined as a consensus failure result.
It should be noted that the above-mentioned manner of commonly identifying the blocks based on the data integrity constraint rule is only a feasible example, and the manner of commonly identifying the blocks based on the data integrity constraint rule is not limited thereto, for example, the user-defined integrity may also be included in the commonly identifying process, that is, the blocks may be commonly identified based on the entity integrity constraint rule, the domain integrity constraint rule, the referential integrity constraint rule, and the user-defined integrity constraint rule. Other ways of commonly identifying the blocks based on the data integrity constraint rule may be used to improve the reliability and security of the data, which will not be described in detail herein.
It should be noted that the above common knowledge of the primary key value, the foreign key value, and the data type is mainly based on a certain node (e.g., the first node), that is, a single common knowledge node determines whether the primary key value, the foreign key value, and the data type conform to the corresponding data integrity constraint rule. Under the feasible condition, after a certain node obtains the factor consensus sub-results corresponding to the primary key value, the foreign key value and the data type respectively, the node can also communicate with other consensus nodes, and when the factor consensus sub-results of the over-proportional consensus nodes are consistent, the consistent factor consensus sub-result is used as the primary key value, or the foreign key value, or the factor consensus sub-result corresponding to the data type. That is to say, the factor consensus sub-result corresponding to the primary key value, the foreign key value, and the data type is not determined by one consensus node, but may be determined by all the consensus nodes, so as to enhance the rigor and reliability of the data, further improve the robustness of the block chain, and ensure the reliability of the data.
It can be understood that, when the blocks are identified based on the first pre-execution result and the data integrity constraint rule, the blocks may be identified based on the data integrity constraint rule, and then the blocks are identified based on the data integrity constraint rule to obtain an identified result, which is an identified passing result, and then the blocks are identified based on the first pre-execution result to obtain a final identified result; of course, the blocks may also be identified based on the first pre-execution result, and after the identification passes, the blocks are identified based on the data integrity constraint rule to obtain a final identification result. The present application is not limited to the execution order of the two.
The method and the system adopt the relational database to store the data on the block chain, and access the relational database mainly through the structured language query instruction, so that the relational operation can be performed on the transaction data through the structured query language instruction. Because the relational data model can intuitively and flexibly store and access the structured instructions, the complicated incidence relation among the business data can be intuitively and accurately presented through simple instructions, the relational operation can be flexibly and accurately carried out on the transaction data in the application through the structured query language instructions, excessive manpower and time are not needed, the flexibility and the accuracy of the relational operation of the transaction data can be well improved, and the data processing efficiency and the accuracy are further improved; meanwhile, the data integrity constraint of the relational data model can be added in the block chain consensus process, namely the consensus process can not only perform consensus based on the execution result of the transaction data, but also perform consensus based on the data integrity constraint rule, so that the data written into the relational database can be ensured to be in accordance with the data integrity constraint rule, the robustness of the block chain can be further improved, and the accuracy of the written data is improved. In conclusion, the method and the device can improve the flexibility of relation operation of the service data in the block chain service, further improve the data processing efficiency and accuracy, and simultaneously reduce the data processing cost.
Further, please refer to fig. 4, wherein fig. 4 is a system logic architecture diagram according to an embodiment of the present application. As shown in fig. 4, the system logic architecture may include a client, a block-link node cluster. The block link point cluster may be a common node cluster, and the block link points included in the block link point cluster may be common nodes. Each consensus node may include a Remote Procedure Call (RPC) service component, a transaction pool, a consensus engine, a scheduler, a virtual machine, and a storage component. For ease of understanding, various contents included in the system architecture will be described below.
A client: the client may refer to the application client described above, which may refer to the originator of the blockchain transaction or query request. That is, a user may initiate transaction data (or a transaction request, such as a query request) through a client.
RPC service component: the RPC service component can provide a service API of the block chain for the client, and after the client initiates transaction data, if the block chain node receives the transaction data, the RPC service component in the block chain node can send the transaction data to the transaction pool; and when a client initiates a transaction request (e.g., a query request), the RPC service component may invoke the virtual machine to execute the query request, wherein a query for existing data in the blockchain may directly access the storage component.
A transaction pool: the transaction pool is used for temporarily caching the received new transaction data, and a virtual machine can be called for the newly received transaction data to check whether the transaction data is valid; when a new block needs to be generated, a batch of transaction data is taken out from the transaction pool and packaged into a block, and after the block is submitted, the batch of transaction data can be cleaned from the transaction pool.
A consensus engine: the consensus engine may be configured to be responsible for consensus among the blockchain, and the consensus engine may communicate with other blockchain nodes (e.g., consensus nodes) to ensure that honest nodes in the blockchain can agree on a new block through consensus. If a match is achieved (e.g., the results of more than a percentage of the consensus nodes are consistent), a new block may be committed; if the agreement is not reached, the proposal for the new block may be rolled back. It should be noted that, in the present application, when the consensus engine performs consensus with other blockchain nodes, in addition to performing consensus on the execution result of the intelligent contract, it is also necessary to perform consensus on the data integrity constraint rule of the relational data model, and a transaction that does not satisfy the data integrity constraint rule is consistently rejected. For a specific implementation manner of identifying the blocks based on the execution result (e.g., the pre-execution result) and the data integrity constraint rule, reference may be made to the description in the embodiments corresponding to fig. 2 to fig. 3, which will not be described herein again.
A scheduler: the scheduler is mainly responsible for scheduling block processing, and can be used for responding to a block request (such as an uplink request or a consensus request) of the consensus engine, and calling an intelligent contract corresponding to the transaction data in the virtual machine execution block so as to pre-execute the transaction data in the block; at the same time, the scheduler may also invoke the storage component to store the content in the chunk. It should be noted that, in the block verification stage, the scheduler in the present application may also schedule the storage component to open a database transaction, where the database transaction is used to execute a structured query language command (such as an SQL command) generated by all transaction data in the block, so that the content of the final block consensus verification may be included, and the execution result of the SQL command may be included, thereby improving the robustness of the block chain.
Virtual machine: the virtual machine is mainly an execution environment of the intelligent contract, and when the intelligent contract is called by the dispatcher, the intelligent contract can be executed in the virtual machine. It should be noted that, the block chain in the present application is a block chain based on a relational data model, and the virtual machine needs to provide an API for supporting the relational operation for the intelligent contract, so as to allow the intelligent contract developer to operate the relational database through SQL. When the virtual machine runs the intelligent contract, if the SQL command is analyzed, the SQL command can be transmitted to the storage component, so that the storage component can execute the corresponding relational operation of the relational database.
A storage component: the storage component is mainly used for storing data on the block chain. In the block chain of the relational data model, the atomicity of data operation needs to be guaranteed, and the storage component can organize all SQL commands related to all transaction data in the block and submit the SQL commands in a single transaction mode (called a database transaction, such as the initial database transaction and the target database transaction). Before the transaction is submitted, whether the SQL command can be successfully executed or not needs to be verified in time when the transaction is executed in a simulation mode (pre-execution mode), and the fact that the relational database can be successfully modified by the commonly recognized transaction data is guaranteed.
For a specific implementation manner of identifying the blocks by each component in one block chain node and storing the blocks in the block chain, reference may be made to the description in the embodiments corresponding to fig. 2 to 3 for identifying the blocks by the first node and storing the blocks in the block chain, which will not be described again here.
In the embodiment of the application, the data on the block chain is stored by adopting the relational database, and the relational database is mainly accessed by the structured language query instruction, so that the relational operation can be performed on the transaction data by the structured query language instruction. Because the relational data model can intuitively and flexibly store and access the structured instructions, the complicated incidence relation among the business data can be intuitively and accurately presented through simple instructions, the relational operation can be flexibly and accurately carried out on the transaction data in the application through the structured query language instructions, excessive manpower and time are not needed, the flexibility and the accuracy of the relational operation of the transaction data can be well improved, and the data processing efficiency and the accuracy are further improved; meanwhile, the data integrity constraint of the relational data model can be added in the block chain consensus process, namely the consensus process can not only perform consensus based on the execution result of the transaction data, but also perform consensus based on the data integrity constraint rule, so that the data written into the relational database can be ensured to be in accordance with the data integrity constraint rule, the robustness of the block chain can be further improved, and the accuracy of the written data is improved. In conclusion, the method and the device can improve the flexibility of relation operation of the service data in the block chain service, further improve the data processing efficiency and accuracy, and simultaneously reduce the data processing cost.
For ease of understanding, please refer to fig. 5, fig. 5 is a flow chart of a system provided in an embodiment of the present application. The system flow mainly refers to an execution flow of each component in a block chain node for a new block, wherein each component included in the block chain node is mainly as shown in fig. 4. As shown in fig. 5, the flow may include at least the following steps S41-S49:
in step S41, the consensus engine initiates a request to the scheduler to verify the chunk.
Specifically, the request for verifying the block may be a consensus request (or uplink request) for the block, and the consensus engine may initiate a block verification request (consensus request) to the scheduler when a new block is proposed or received from another consensus node.
In step S42, the scheduler issues a request to the storage component to start block pre-execution.
Specifically, the scheduler may call the memory component to initiate the block pre-execution command after receiving the block verification request.
In step S43, the storage component opens a database transaction.
Specifically, the database transaction may correspond to the initial database transaction, and the storage component may open a database transaction, obtain and maintain a transaction handle. It should be understood that the SQL commands that need to be executed for all transactional data in the current block may be executed in the database transaction.
In step S44, the dispatcher sends a request to the virtual machine to simulate execution of the transaction data.
Specifically, the scheduler may send execution requests for the transaction data in the block to the virtual machine in sequence.
In step S45, the virtual machine accesses transaction data.
Specifically, the virtual machine may invoke and execute a corresponding intelligent contract according to the content of each transaction data. During execution of the intelligent contract, if a request to access the relational database is parsed (e.g., a structured query language instruction such as SQL is parsed), the virtual machine may send the structured query language instruction to the storage component.
In step S46, the storage component executes the structured query language instructions.
Specifically, the structured query language instruction may refer to an SQL command, and the storage component may sequentially execute all SQL commands in one transaction data to simulate execution of corresponding transaction data. It should be noted that, when all SQL commands in a transaction are executed successfully, corresponding fields (which may be referred to as save fields, such as SAVEPOINT) in the SQL standard may be called to set save points, and if an exception is encountered during the execution of the current transaction data, the data may be rolled back to the save point set in the previous normal transaction data, and the write operation of a certain abnormal transaction data in the block to the relational database may be rolled back by way of the save points, without affecting the write operation of the normal transaction data in the block.
In step S47, the consensus engine initiates a command to commit or undo a chunk.
Specifically, if the block verification is successful (if the consensus result of the block is a consensus pass result), the consensus engine may initiate a command to the scheduler to submit the block; conversely, if the block authentication fails (e.g., the consensus of the block is a consensus failure result), the consensus engine may initiate a command to the scheduler to revoke the block.
In step S48, the scheduler sends a command to the storage component to commit or revoke the chunk.
Specifically, the scheduler may send a command to the storage component after receiving the command to commit or undo the chunk.
In step S49, the storage component commits or rolls back the database transaction.
Specifically, if the storage component receives a command submitted by a block, a database transaction of the whole block can be submitted, and atomicity of write operation in the block is ensured; if the memory component receives a command to undo the block, the memory component may rollback the database transaction for the entire block, causing the database to rollback to a state prior to pre-execution of the block.
Specifically, for a specific implementation manner of step S41-step S49, reference may be made to the description in the embodiment corresponding to fig. 2-fig. 3, and details will not be repeated here.
In the embodiment of the application, the data on the block chain is stored by adopting the relational database, and the relational database is mainly accessed by the structured language query instruction, so that the relational operation can be performed on the transaction data by the structured query language instruction. Because the relational data model can intuitively and flexibly store and access the structured instructions, the complicated incidence relation among the business data can be intuitively and accurately presented through simple instructions, the relational operation can be flexibly and accurately carried out on the transaction data in the application through the structured query language instructions, excessive manpower and time are not needed, the flexibility and the accuracy of the relational operation of the transaction data can be well improved, and the data processing efficiency and the accuracy are further improved; meanwhile, the data integrity constraint of the relational data model can be added in the block chain consensus process, namely the consensus process can not only perform consensus based on the execution result of the transaction data, but also perform consensus based on the data integrity constraint rule, so that the data written into the relational database can be ensured to be in accordance with the data integrity constraint rule, the robustness of the block chain can be further improved, and the accuracy of the written data is improved.
Further, please refer to fig. 6, where fig. 6 is a schematic structural diagram of a data processing apparatus according to an embodiment of the present application. The data processing means may be a computer program (comprising program code) running on a computer device, for example the data processing means being an application software; the data processing apparatus may be adapted to perform the method illustrated in fig. 3. As shown in fig. 6, the data processing apparatus 1 may include: a request receiving module 11, an execution result obtaining module 12, a block identifying module 13, and a block storing module 14.
A request receiving module 11, configured to receive an uplink request for a block sent by a second node; the uplink request is used for requesting to store the block into a relational database corresponding to the block chain, wherein the relational database is established based on a relational data model;
an execution result obtaining module 12, configured to obtain a first pre-execution result of the transaction data in the block based on the uplink request;
the block consensus module 13 is configured to perform consensus on the blocks according to the first pre-execution result and the data integrity constraint rule indicated by the relational data model, so as to obtain a consensus result of the blocks; the first pre-execution result is an execution result obtained after the first node pre-executes the transaction associated operation related to the transaction data based on the structured query language instruction corresponding to the transaction data; the structured query language instruction is an instruction for operating the relational database to execute transaction correlation operation;
and the block storage module 14 is configured to store the block into the relational database when the consensus result of the block is the consensus pass result.
For a specific implementation manner of the request receiving module 11, the execution result obtaining module 12, the block consensus module 13, and the block storage module 14, reference may be made to the description of step S101 to step S103 in the embodiment corresponding to fig. 2, which will not be described herein again.
In one embodiment, the execution result obtaining module 12 may include: a transaction creation unit 121, an instruction execution unit 122, and a result determination unit 123.
A transaction creation unit 121, configured to create an initial database transaction for a block based on the uplink request;
an instruction execution unit 122, configured to execute a structured query language instruction indicated by the transaction correlation operation in the initial database transaction, to obtain an instruction execution result;
a result determination unit 123 for determining the instruction execution result as a first pre-execution result of the transaction data.
For specific implementation manners of the transaction creating unit 121, the instruction executing unit 122, and the result determining unit 123, reference may be made to the description of step S102 in the embodiment corresponding to fig. 2, and details are not repeated here.
In one embodiment, the block storage module 14 may include: a target transaction acquisition unit 141 and a transaction storage unit 142.
A target transaction obtaining unit 141, configured to obtain a target database transaction associated with a block; the target database transaction comprises a structured query language instruction in the transaction data and a first pre-execution result;
and a transaction storage unit 142, configured to store the target database transaction in the relational database.
For specific implementation manners of the target transaction obtaining unit 141 and the transaction storage unit 142, reference may be made to the description of step S103 in the embodiment corresponding to fig. 2, and details are not repeated here.
In one embodiment, the uplink request carries a second pre-execution result, where the second pre-execution result is an execution result obtained after the second node performs pre-execution on the transaction relationship operation in the transaction data based on the structured query language instruction in the transaction data;
the block consensus module 13 may include: a result comparing unit 131, a factor identifying unit 132, a first result determining unit 133, and a second result determining unit 134.
A result comparing unit 131, configured to compare the first pre-execution result with the second pre-execution result to obtain a comparison result;
a factor consensus unit 132, configured to, if the comparison result between the first pre-execution result and the second pre-execution result is a matching result, obtain, based on the data integrity constraint rule indicated by the relational data model, a primary key value included in the structured query language instruction, an external key value included in the structured query language instruction, and a data type corresponding to the structured query language instruction;
the factor consensus unit 132 is further configured to perform consensus on the primary key value, the foreign key value, and the data type to obtain a factor consensus result corresponding to the primary key value, the foreign key value, and the data type;
a first result determining unit 133 for determining the factor consensus result as a consensus result of the blocks;
the second result determining unit 134 is configured to determine that the block consensus result is a consensus failure result if the comparison result between the first pre-execution result and the second pre-execution result is a mismatch result.
For a specific implementation manner of the result comparing unit 131, the factor identifying unit 132, the first result determining unit 133, and the second result determining unit 134, reference may be made to the description of step S102 in the embodiment corresponding to fig. 2, and details will not be described here.
In one embodiment, the number of the second nodes is at least two, and the number of the second pre-execution results is at least two;
the result comparing unit 131 may include: a same result obtaining sub-unit 1311, an operation sub-unit 1312, a number statistics sub-unit 1313, a ratio determining sub-unit 1314 and a comparison result determining sub-unit 1315.
A same result obtaining subunit 1311, configured to form a pre-execution result set according to the at least two second pre-execution results and the first pre-execution result, and determine a pre-execution result that is a same result in the pre-execution result set as a pre-execution result to be counted;
an operation subunit 1312, configured to count the number of pre-execution results to be counted, and use the number of pre-execution results to be counted as a statistical number;
a number counting subunit 1313, configured to count a total number of results corresponding to the first pre-execution result and the at least two second pre-execution results;
a ratio determining subunit 1314 for determining a number ratio between the number of operations and the total number of results;
the comparison result determining subunit 1315 is configured to determine a comparison result between the first pre-execution result and the second pre-execution result according to the number ratio.
For a specific implementation manner of the same result obtaining subunit 1311, the operation subunit 1312, the quantity statistics subunit 1313, the ratio determining subunit 1314, and the comparison result determining subunit 1315, reference may be made to the description of step S102 in the embodiment corresponding to fig. 2, which will not be described herein again.
In an embodiment, the comparison result determining subunit 1315 is further specifically configured to compare the number ratio with a ratio threshold;
the comparison result determining subunit 1315 is further specifically configured to determine, if the number ratio is greater than the ratio threshold, a comparison result between the first pre-execution result and the second pre-execution result as a matching result;
the comparison result determining subunit 1315 is further specifically configured to determine, if the number ratio is smaller than the ratio threshold, a comparison result between the first pre-execution result and the second pre-execution result as a mismatch result.
In one embodiment, the factor consensus unit 132 may include: a first factor consensus unit 1321, a second factor consensus unit 1322, a third factor consensus unit 1323, and a consensus result determining unit 1324.
A first factor consensus subunit 1321, configured to perform consensus on the primary key value to obtain a first factor consensus sub-result corresponding to the primary key value;
a second factor consensus sub-unit 1322, configured to perform consensus on the foreign key value to obtain a second factor consensus sub-result corresponding to the foreign key value;
a third factor consensus subunit 1323, configured to perform consensus on the data types to obtain a third factor consensus sub-result corresponding to the data types;
the consensus result determining subunit 1324 is configured to determine, according to the first factor consensus sub-result, the second factor consensus sub-result, and the third factor consensus sub-result, a factor consensus result corresponding to the primary key value, the foreign key value, and the data type.
The specific implementation manners of the first factor consensus subunit 1321, the second factor consensus subunit 1322, the third factor consensus subunit 1323, and the consensus result determination subunit 1324 may refer to the descriptions of step S301 to step S304 in the embodiment corresponding to fig. 3, which will not be described herein again.
In one embodiment, the data integrity constraint rules include uniqueness constraint rules configured for primary key values;
the first factor consensus subunit 1321 is further specifically configured to obtain a target entity object indicated by the primary key value;
the first factor consensus subunit 1321 is further specifically configured to traverse a set of stored entity objects included in the relational database based on a uniqueness constraint rule;
the first factor consensus subunit 1321 is further specifically configured to, if there is no stored entity object in the set of stored entity objects that is the same as the target entity object, determine the target entity object as the unique entity object, and determine the first factor consensus sub result corresponding to the primary key value as a factor consensus passing result;
the first factor consensus sub-unit 1321 is further specifically configured to determine, if a stored entity object identical to the target entity object exists in the stored entity object set, the target entity object as a duplicate entity object, and determine the first factor consensus sub-result corresponding to the primary key value as a factor consensus failure result.
In one embodiment, the data integrity constraint rules include a referential validity constraint rule configured for foreign key values;
the second factor consensus subunit 1322 is further specifically configured to determine, in the structured query language instruction, a reference object indicated by the foreign key value and an object file to which the reference object belongs, based on the reference validity constraint rule;
the second factor consensus subunit 1322 is further specifically configured to acquire an object file and traverse the object file;
the second factor consensus sub-unit 1322 is further specifically configured to, if the object file includes the reference object, determine the reference object as the valid reference object, and determine the second factor consensus sub-result corresponding to the foreign key value as the factor consensus passing result;
the second factor consensus sub-unit 1322 is further specifically configured to, if the reference object is not included in the object file, determine the reference object as an invalid reference object, and determine the second factor consensus sub-result corresponding to the foreign key value as a factor consensus failure result.
In one embodiment, the data integrity constraint rule comprises a set of standard data types supported by a relational database;
a third factor consensus subunit 1323, further specifically configured to traverse the set of standard data types;
the third factor consensus subunit 1323 is further specifically configured to, if a standard data type that is the same as the data type exists in the standard data type set, determine the data type as an effective data type, and determine a third factor consensus sub-result corresponding to the data type as a factor consensus passing result;
the third factor consensus sub-unit 1323 is further specifically configured to determine the data type as an invalid data type if the standard data type that is the same as the data type does not exist in the standard data type set, and determine the third factor consensus sub-result corresponding to the data type as a factor consensus failure result.
In an embodiment, the consensus result determining subunit 1324 is further specifically configured to determine, if the first factor consensus sub-result, the second factor consensus sub-result, and the third factor consensus sub-result are all factor consensus pass results, the factor consensus result corresponding to the primary key value, the foreign key value, and the data type is determined as a consensus pass result;
the consensus result determining subunit 1324 is further specifically configured to determine, if at least one of the first factor consensus sub-result, the second factor consensus sub-result, and the third factor consensus sub-result is a factor consensus failure result, the factor consensus result corresponding to the primary key value, the foreign key value, and the data type together is the consensus failure result.
In one embodiment, the uplink request carries a digital signature; the digital signature is obtained by the second node after the second node signs the block based on the private key of the second node;
the block-based data processing apparatus 1 may further include: a signature verification module 15, a step execution module 16 and a communication pause module 17.
The signature verification module 15 is configured to obtain a public key of the second node, and verify the digital signature based on the public key;
a step executing module 16, configured to execute a first pre-execution result of obtaining the transaction data in the block based on the uplink request if the signature verification passes, and perform consensus on the block according to the first pre-execution result and a data integrity constraint rule indicated by the relational data model to obtain a consensus result of the block;
and the communication suspending module 17 is configured to mark the second node as an abnormal node if the verification is failed, and suspend data communication with the abnormal node within the target time period.
For specific implementation manners of the signature verification module 15, the step execution module 16, and the communication suspension module 17, reference may be made to the description of step S102 in the embodiment corresponding to fig. 2, which will not be described herein again.
In the embodiment of the application, the data on the block chain is stored by adopting the relational database, and the relational database is mainly accessed by the structured language query instruction, so that the relational operation can be performed on the transaction data by the structured query language instruction. Because the relational data model can intuitively and flexibly store and access the structured instructions, the complicated incidence relation among the business data can be intuitively and accurately presented through simple instructions, the relational operation can be flexibly and accurately carried out on the transaction data in the application through the structured query language instructions, excessive manpower and time are not needed, the flexibility and the accuracy of the relational operation of the transaction data can be well improved, and the data processing efficiency and the accuracy are further improved; meanwhile, the data integrity constraint of the relational data model can be added in the block chain consensus process, namely the consensus process can not only perform consensus based on the execution result of the transaction data, but also perform consensus based on the data integrity constraint rule, so that the data written into the relational database can be ensured to be in accordance with the data integrity constraint rule, the robustness of the block chain can be further improved, and the accuracy of the written data is improved. In conclusion, the method and the device can improve the flexibility of relation operation of the service data in the block chain service, further improve the data processing efficiency and accuracy, and simultaneously reduce the data processing cost.
Further, please refer to fig. 7, where fig. 7 is a schematic structural diagram of a computer device according to an embodiment of the present application. As shown in fig. 7, the data processing apparatus 1 based on the block chain in the embodiment corresponding to fig. 6 may be applied to the computer device 8000, and the computer device 8000 may include: a processor 8001, a network interface 8004, and a memory 8005, and the computer device 8000 further includes: a user interface 8003, and at least one communication bus 8002. The communication bus 8002 is used for connection communication between these components. The user interface 8003 may include a Display (Display) and a Keyboard (Keyboard), and the optional user interface 8003 may further include a standard wired interface and a wireless interface. The network interface 8004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). Memory 8005 may be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory. Memory 8005 may optionally also be at least one storage device located remotely from the aforementioned processor 8001. As shown in fig. 7, the memory 8005, which is a kind of computer readable storage medium, may include therein an operating system, a network communication module, a user interface module, and a device control application program.
In the computer device 8000 of fig. 7, a network interface 8004 may provide network communication functions; and user interface 8003 is primarily an interface for providing input to a user; and processor 8001 may be used to invoke a device control application stored in memory 8005 to implement:
receiving an uplink request for a block sent by a second node; the uplink request is used for requesting to store the block into a relational database corresponding to the block chain, wherein the relational database is established based on a relational data model;
acquiring a first pre-execution result of transaction data in a block based on the uplink request, and performing consensus on the block according to the first pre-execution result and a data integrity constraint rule indicated by the relational data model to obtain a consensus result of the block; the first pre-execution result is an execution result obtained after the first node pre-executes the transaction associated operation related to the transaction data based on the structured query language instruction corresponding to the transaction data; the structured query language instruction is an instruction for operating the relational database to execute transaction correlation operation;
and when the consensus result of the block is a consensus passing result, storing the block into the relational database.
It should be understood that the computer device 8000 described in this embodiment may perform the description of the data processing method based on the block chain in the embodiment corresponding to fig. 2 to fig. 3, and may also perform the description of the data processing apparatus 1 based on the block chain in the embodiment corresponding to fig. 6, which is not described herein again. In addition, the beneficial effects of the same method are not described in detail.
Further, here, it is to be noted that: an embodiment of the present application further provides a computer-readable storage medium, and the computer-readable storage medium stores therein a computer program executed by the aforementioned data processing computer device 8000, and the computer program includes program instructions, and when the processor executes the program instructions, the descriptions of the data processing method based on the partition chain in the embodiments corresponding to fig. 2 to fig. 3 can be executed, so that details are not repeated here. In addition, the beneficial effects of the same method are not described in detail. For technical details not disclosed in the embodiments of the computer-readable storage medium referred to in the present application, reference is made to the description of the embodiments of the method of the present application.
The computer readable storage medium may be the data processing apparatus provided in any of the foregoing embodiments or an internal storage unit of the computer device, such as a hard disk or a memory of the computer device. The computer readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Memory Card (SMC), a Secure Digital (SD) card, a flash card (flash card), and the like, provided on the computer device. Further, the computer-readable storage medium may also include both an internal storage unit and an external storage device of the computer device. The computer-readable storage medium is used for storing the computer program and other programs and data required by the computer device. The computer readable storage medium may also be used to temporarily store data that has been output or is to be output.
In one aspect of the application, a computer program product or computer program is provided, the computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the method provided by one aspect of the embodiments of the present application.
The terms "first," "second," and the like in the description and in the claims and drawings of the embodiments of the present application are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "comprises" and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product, or apparatus that comprises a list of steps or elements is not limited to the listed steps or modules, but may alternatively include other steps or modules not listed or inherent to such process, method, apparatus, product, or apparatus.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be embodied in electronic hardware, computer software, or combinations of both, and that the components and steps of the examples have been described in a functional general in the foregoing description for the purpose of illustrating clearly the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The method and the related apparatus provided by the embodiments of the present application are described with reference to the flowchart and/or the structural diagram of the method provided by the embodiments of the present application, and each flow and/or block of the flowchart and/or the structural diagram of the method, and the combination of the flow and/or block in the flowchart and/or the block diagram can be specifically implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block or blocks of the block diagram. These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block or blocks of the block diagram. These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block or blocks.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present application and is not to be construed as limiting the scope of the present application, so that the present application is not limited thereto, and all equivalent variations and modifications can be made to the present application.

Claims (16)

1. A data processing method based on a block chain is characterized by comprising the following steps:
a first node receives an uplink request aiming at a block sent by a second node; the uplink request is used for requesting the block to be stored in a relational database corresponding to the block chain, wherein the relational database is established based on a relational data model;
acquiring a first pre-execution result of transaction data in the block based on the uplink request, and performing consensus on the block according to the first pre-execution result and a data integrity constraint rule indicated by the relational data model to obtain a consensus result of the block; the first pre-execution result is an execution result obtained after the first node pre-executes the transaction association operation related to the transaction data based on the structured query language instruction corresponding to the transaction data; the structured query language instruction refers to an instruction for operating the relational database to execute the transaction correlation operation;
and when the consensus result of the block is a consensus passing result, storing the block into the relational database.
2. The method of claim 1 wherein said obtaining a first pre-execution result of transaction data in said block based on said uplink request comprises:
creating an initial database transaction for the block based on the uplink request;
in the initial database transaction, executing the structured query language instruction indicated by the transaction correlation operation to obtain an instruction execution result;
determining the instruction execution result as a first pre-execution result of the transaction data.
3. The method of claim 1, wherein storing the tile in the relational database comprises:
obtaining a target database transaction associated with the block; the target database transaction comprises the structured query language instruction in the transaction data and the first pre-execution result;
and storing the target database transaction into the relational database.
4. The method of claim 1 wherein the uplink request carries a second pre-execution result, the second pre-execution result being an execution result obtained by the second node pre-executing the transaction relationship operation in the transaction data based on a structured query language instruction in the transaction data;
the consensus on the blocks according to the first pre-execution result and the data integrity constraint rule indicated by the relational data model to obtain the consensus result of the blocks includes:
comparing the first pre-execution result with the second pre-execution result to obtain a comparison result;
if the comparison result between the first pre-execution result and the second pre-execution result is a matching result, acquiring a primary key value contained by the structured query language instruction, an foreign key value contained by the structured query language instruction and a data type corresponding to the structured query language instruction based on a data integrity constraint rule indicated by the relational data model, commonly identifying the primary key value, the foreign key value and the data type to obtain a factor common identification result commonly corresponding to the primary key value, the foreign key value and the data type, and determining the factor common identification result as the common identification result of the block;
and if the comparison result between the first pre-execution result and the second pre-execution result is a mismatch result, the consensus result of the blocks is a consensus failure result.
5. The method of claim 4, wherein the number of the second nodes is at least two, and the number of the second pre-execution results is at least two;
the comparing the first pre-execution result with the second pre-execution result to obtain a comparison result includes:
forming a pre-execution result set according to at least two second pre-execution results and the first pre-execution result, and determining the pre-execution results which are the same in the pre-execution result set as pre-execution results to be counted;
counting the number of the pre-execution results to be counted, and taking the number of the pre-execution results to be counted as a counting number;
counting the total number of the first pre-execution result and the results corresponding to the at least two second pre-execution results;
determining a quantity ratio between the statistical quantity and the total quantity of the results, and determining the comparison result between the first pre-execution result and the second pre-execution result according to the quantity ratio.
6. The method of claim 5, wherein the determining the comparison between the first pre-execution result and the second pre-execution result according to the quantity ratio comprises:
comparing the quantity ratio to a ratio threshold;
if the number ratio is larger than the ratio threshold, determining the comparison result between the first pre-execution result and the second pre-execution result as a matching result;
if the number ratio is smaller than the ratio threshold, determining the comparison result between the first pre-execution result and the second pre-execution result as a mismatch result.
7. The method according to claim 4, wherein the obtaining a result of common factor consensus among the primary key value, the foreign key value, and the data type by performing common consensus among the primary key value, the foreign key value, and the data type includes:
performing consensus on the primary key values to obtain first factor consensus sub-results corresponding to the primary key values;
performing consensus on the foreign key values to obtain a second factor consensus sub-result corresponding to the foreign key values;
performing consensus on the data types to obtain a third factor consensus sub-result corresponding to the data types;
and determining a factor consensus result corresponding to the primary key value, the foreign key value and the data type according to the first factor consensus sub-result, the second factor consensus sub-result and the third factor consensus sub-result.
8. The method of claim 7, wherein the data integrity constraint rule comprises a uniqueness constraint rule configured for the primary key value;
the obtaining a first factor consensus sub-result corresponding to the primary key value by performing consensus on the primary key value includes:
acquiring a target entity object indicated by the primary key value;
traversing a set of stored entity objects contained in the relational database based on the uniqueness constraint rule;
if the stored entity object which is the same as the target entity object does not exist in the stored entity object set, determining the target entity object as a unique entity object, and determining a first factor consensus sub-result corresponding to the primary key value as a factor consensus passing result;
and if the stored entity object identical to the target entity object exists in the stored entity object set, determining the target entity object as a repeated entity object, and determining a first factor consensus sub-result corresponding to the primary key value as a factor consensus failure result.
9. The method of claim 7, wherein the data integrity constraint rule comprises a referential validity constraint rule configured for the foreign key value;
the obtaining a second factor consensus sub-result corresponding to the foreign key value by performing consensus on the foreign key value includes:
determining a reference object indicated by the foreign key value and an object file to which the reference object belongs in the structured query language instruction based on the reference validity constraint rule;
acquiring the object file and traversing the object file;
if the object file contains the reference object, determining the reference object as an effective reference object, and determining a second factor consensus sub-result corresponding to the foreign key value as a factor consensus passing result;
and if the reference object is not contained in the object file, determining the reference object as an invalid reference object, and determining a second factor consensus sub-result corresponding to the foreign key value as a factor consensus failure result.
10. The method of claim 7, wherein the data integrity constraint rule comprises a set of standard data types supported by the relational database;
the obtaining a third factor consensus sub-result corresponding to the data type by performing consensus on the data type includes:
traversing the set of standard data types;
if the standard data type same as the data type exists in the standard data type set, determining the data type as an effective data type, and determining a third factor consensus sub-result corresponding to the data type as a factor consensus passing result;
if the standard data type same as the data type does not exist in the standard data type set, determining the data type as an invalid data type, and determining a third factor consensus sub-result corresponding to the data type as a factor consensus failure result.
11. The method of claim 7, wherein determining the factor consensus result corresponding to the primary key value, the foreign key value, and the data type in common according to the first factor consensus sub-result, the second factor consensus sub-result, and the third factor consensus sub-result comprises:
if the first factor consensus sub-result, the second factor consensus sub-result and the third factor consensus sub-result are all factor consensus pass results, determining the factor consensus results corresponding to the primary key value, the foreign key value and the data type as consensus pass results;
and if at least one factor consensus sub-result among the first factor consensus sub-result, the second factor consensus sub-result and the third factor consensus sub-result is a factor consensus failure result, determining the factor consensus result corresponding to the primary key value, the foreign key value and the data type as a consensus failure result.
12. The method of claim 1 wherein the uplink request carries a digital signature; the digital signature is obtained by the second node after the second node signs the block based on the private key of the second node;
the method further comprises the following steps:
acquiring a public key of the second node, and verifying the digital signature based on the public key;
if the check label passes, executing a first pre-execution result of the transaction data in the block obtained based on the uplink request, and performing consensus on the block according to the first pre-execution result and a data integrity constraint rule indicated by the relational data model to obtain a consensus result of the block;
if the verification and signing are not passed, the second node is marked as an abnormal node, and data communication with the abnormal node is suspended in a target time period.
13. A blockchain-based data processing apparatus, comprising:
a request receiving module, configured to receive an uplink request for a block sent by a second node; the uplink request is used for requesting the block to be stored in a relational database corresponding to the block chain, wherein the relational database is established based on a relational data model;
an execution result obtaining module, configured to obtain a first pre-execution result of the transaction data in the block based on the uplink request;
the block consensus module is used for performing consensus on the blocks according to the first pre-execution result and the data integrity constraint rule indicated by the relational data model to obtain a consensus result of the blocks; the first pre-execution result is an execution result obtained after the first node pre-executes the transaction association operation related to the transaction data based on the structured query language instruction corresponding to the transaction data; the structured query language instruction refers to an instruction for operating the relational database to execute the transaction correlation operation;
and the block storage module is used for storing the blocks into the relational database when the consensus result of the blocks is a consensus passing result.
14. A computer device, comprising: a processor, a memory, and a network interface;
the processor is connected to the memory and the network interface, wherein the network interface is configured to provide a network communication function, the memory is configured to store a computer program, and the processor is configured to call the computer program to cause the computer device to perform the method of any one of claims 1 to 12.
15. A computer-readable storage medium, in which a computer program is stored which is adapted to be loaded by a processor and to carry out the method of any one of claims 1 to 12.
16. A computer program product, characterized in that the computer program product comprises a computer program stored in a computer readable storage medium, the computer program being adapted to be read and executed by a processor to cause a computer device having the processor to perform the method of any of claims 1-12.
CN202210609432.7A 2022-05-31 2022-05-31 Data processing method, device and equipment based on block chain and readable storage medium Pending CN115114372A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210609432.7A CN115114372A (en) 2022-05-31 2022-05-31 Data processing method, device and equipment based on block chain and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210609432.7A CN115114372A (en) 2022-05-31 2022-05-31 Data processing method, device and equipment based on block chain and readable storage medium

Publications (1)

Publication Number Publication Date
CN115114372A true CN115114372A (en) 2022-09-27

Family

ID=83327028

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210609432.7A Pending CN115114372A (en) 2022-05-31 2022-05-31 Data processing method, device and equipment based on block chain and readable storage medium

Country Status (1)

Country Link
CN (1) CN115114372A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116684425A (en) * 2023-07-28 2023-09-01 腾讯科技(深圳)有限公司 Block chain data processing method, system, device and computer equipment
CN117591303A (en) * 2024-01-18 2024-02-23 腾讯科技(深圳)有限公司 Business processing method based on block chain, block chain system, medium and equipment

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116684425A (en) * 2023-07-28 2023-09-01 腾讯科技(深圳)有限公司 Block chain data processing method, system, device and computer equipment
CN116684425B (en) * 2023-07-28 2023-10-27 腾讯科技(深圳)有限公司 Block chain data processing method, system, device and computer equipment
CN117591303A (en) * 2024-01-18 2024-02-23 腾讯科技(深圳)有限公司 Business processing method based on block chain, block chain system, medium and equipment
CN117591303B (en) * 2024-01-18 2024-05-07 腾讯科技(深圳)有限公司 Business processing method based on block chain, block chain system, medium and equipment

Similar Documents

Publication Publication Date Title
US11743137B2 (en) Systems, methods, and apparatuses for implementing a metadata driven rules engine on blockchain using distributed ledger technology (DLT)
US11811769B2 (en) Systems, methods, and apparatuses for implementing a declarative, metadata driven, cryptographically verifiable multi-network (multi-tenant) shared ledger
US11469886B2 (en) System or method to implement record level access on metadata driven blockchain using shared secrets and consensus on read
US11899817B2 (en) Systems, methods, and apparatuses for storing PII information via a metadata driven blockchain using distributed and decentralized storage for sensitive user information
US11886421B2 (en) Systems, methods, and apparatuses for distributing a metadata driven application to customers and non-customers of a host organization using distributed ledger technology (DLT)
US11824864B2 (en) Systems, methods, and apparatuses for implementing a declarative and metadata driven blockchain platform using distributed ledger technology (DLT)
US11824970B2 (en) Systems, methods, and apparatuses for implementing user access controls in a metadata driven blockchain operating via distributed ledger technology (DLT) using granular access objects and ALFA/XACML visibility rules
US11875400B2 (en) Systems, methods, and apparatuses for dynamically assigning nodes to a group within blockchains based on transaction type and node intelligence using distributed ledger technology (DLT)
US20200250177A1 (en) Systems, methods, and apparatuses for implementing an sql query and filter mechanism for blockchain stored data using distributed ledger technology (dlt)
US20200250295A1 (en) Systems, methods, and apparatuses for protecting consumer data privacy using solid, blockchain and ipfs integration
JP2022529967A (en) Extracting data from the blockchain network
KR20200011435A (en) Parameterizable Smart Contract
US20180183600A1 (en) Method and system for providing validated, auditable, and immutable inputs to a smart contract
JP2021525931A (en) Efficient verification for blockchain
CN112840617A (en) Block chain notification board for storing block chain resources
US10958420B2 (en) Method and system for blockchain-implemented project management
CN115114372A (en) Data processing method, device and equipment based on block chain and readable storage medium
JP2023513848A (en) Computing services for blockchain-related service platforms
US20230342437A1 (en) Blockchain-based system and method for publishing an operating system
US20230334344A1 (en) Distributed ledger based machine-learning model management
CN117121440A (en) Uniform resource identifier
CN117057806B (en) Data processing method and device based on block chain and related equipment
CN118520442A (en) Data processing method, device, equipment and readable storage medium
CN115062349A (en) Data asset management system, method and device, storage medium and electronic equipment
CN118467626A (en) Data processing method, device, equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination