CN116804949B - Block chain-based data processing method, device, equipment and readable storage medium - Google Patents

Block chain-based data processing method, device, equipment and readable storage medium Download PDF

Info

Publication number
CN116804949B
CN116804949B CN202310942048.3A CN202310942048A CN116804949B CN 116804949 B CN116804949 B CN 116804949B CN 202310942048 A CN202310942048 A CN 202310942048A CN 116804949 B CN116804949 B CN 116804949B
Authority
CN
China
Prior art keywords
contract
container unit
process container
transaction
contract process
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.)
Active
Application number
CN202310942048.3A
Other languages
Chinese (zh)
Other versions
CN116804949A (en
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 CN202310942048.3A priority Critical patent/CN116804949B/en
Publication of CN116804949A publication Critical patent/CN116804949A/en
Application granted granted Critical
Publication of CN116804949B publication Critical patent/CN116804949B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The application discloses a data processing method, a device, equipment and a readable storage medium based on a blockchain, wherein the method comprises the following steps: receiving a business transaction containing a first contract identifier corresponding to a first intelligent contract through a contract dispatcher container unit, and forwarding the business transaction to a transaction load balancer; in the transaction load balancer, one or more contract process container units associated with a first contract identification are acquired from a contract process container unit set, and a contract process container unit meeting idle scheduling conditions is selected from the one or more contract process container units to serve as a target contract process container unit; and sending the business transaction to a target contract process container unit through a transaction load balancer, and calling a first intelligent contract to execute the business transaction in the target contract process container unit to obtain a transaction execution result. By adopting the method and the device, the dynamic allocation of resources can be realized, and the contract execution efficiency is improved.

Description

Block chain-based data processing method, device, equipment 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 blockchain.
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, and is mainly used for sorting data according to time sequence, encrypting the data into an account book, preventing the account book from being tampered and forged, and simultaneously verifying, storing and updating the data. There is also increasing use for blockchains because of their non-tamperability and authenticity.
For the current blockchain contract engine, the intelligent contracts basically run in a contract process mode, and in order to accelerate the processing speed of transactions, the contract tasks related to the transactions are processed in a mode of concurrent contract multi-process mode. However, when the number of transactions in the blockchain network is excessive, concurrent contract processes repeatedly contend for process resources, and frequent resource scheduling affects contract execution efficiency.
Disclosure of Invention
The embodiment of the application provides a data processing method, a device, equipment and a readable storage medium, which can realize dynamic allocation of resources and improve contract execution efficiency.
In one aspect, the embodiment of the application provides a data processing method based on a blockchain, wherein a blockchain network comprises blockchain nodes and container cluster management nodes corresponding to the blockchain nodes; the container cluster management node comprises a contract dispatcher container unit, a transaction load balancer and a contract process container unit set; the method is performed by a container cluster management node; the method comprises the following steps:
Receiving the business transaction sent by the blockchain node through a contract scheduler container unit, and forwarding the business transaction to a transaction load balancer; the business transaction comprises a first contract identification corresponding to the first intelligent contract;
in the transaction load balancer, one or more contract process container units associated with a first contract identification are acquired from a contract process container unit set, and a contract process container unit meeting idle scheduling conditions is selected from the one or more contract process container units to serve as a target contract process container unit; the one or more contract process container units are provided with a first intelligent contract;
and sending the business transaction to a target contract process container unit through a transaction load balancer, calling a first intelligent contract to execute the business transaction in the target contract process container unit to obtain a transaction execution result, and sending the transaction execution result to the blockchain node.
In one aspect, the present application provides a data processing apparatus based on a blockchain, where a blockchain network includes blockchain nodes and container cluster management nodes corresponding to the blockchain nodes; the container cluster management node comprises a contract dispatcher container unit, a transaction load balancer and a contract process container unit set; the device is operated by a container cluster management node; the device comprises:
The scheduling module is used for receiving the business transaction sent by the blockchain node through the contract scheduler container unit and forwarding the business transaction to the transaction load balancer; the business transaction comprises a first contract identification corresponding to the first intelligent contract;
the load balancing module is used for acquiring one or more contract process container units associated with the first contract identification from the contract process container unit set in the transaction load balancer, and selecting the contract process container unit meeting the idle scheduling condition from the one or more contract process container units as a target contract process container unit; the one or more contract process container units are provided with a first intelligent contract;
and the execution module is used for sending the business transaction to the target contract process container unit through the transaction load balancer, calling the first intelligent contract to execute the business transaction in the target contract process container unit to obtain a transaction execution result, and sending the transaction execution result to the blockchain node.
Wherein, load balancing module includes:
a first obtaining unit, configured to obtain, in a transaction load balancer, one or more contract process container units associated with a first contract identifier from a contract process container unit set;
The second acquisition unit is used for acquiring the computing power resource occupation information corresponding to one or more contract process container units associated with the first contract identification, and determining the contract process container unit with the smallest computing power resource occupation information as the contract process container unit conforming to the idle scheduling condition;
and the determining unit is used for taking the contract process container unit meeting the idle scheduling condition as a target contract process container unit.
Wherein, above-mentioned data processing apparatus still includes:
a receiving module for receiving a contract deployment transaction sent by the blockchain node through a contract scheduler container unit; the contract deployment transaction comprises a second contract identifier corresponding to the second intelligent contract and an intelligent contract code;
the creation module is used for creating a first contract process container unit according to contract deployment transaction; the first contract process container unit contains intelligent contract codes;
the sending module is used for sending the association relation between the contract deployment transaction and the second contract identification and the first contract process container unit to the transaction load balancer;
the forwarding module is used for forwarding the contract deployment transaction to the first contract process container unit according to the association relation between the second contract identification and the first contract process container unit in the transaction load balancer;
The initialization module is used for calling intelligent contract codes to perform contract initialization processing according to contract deployment transaction in the first contract process container unit to obtain a contract initialization result, and sending the contract initialization result to the blockchain node; the contract initialization results are used to characterize deployment of the second intelligent contract in the first contract process container unit.
Wherein the contract dispatcher container unit comprises an initial contract process container unit creation template and a container unit creator;
a creation module comprising:
the third acquisition unit is used for acquiring an initial contract process container unit creation template from the contract dispatcher container unit, updating the initial contract process container unit creation template according to the intelligent contract code, and obtaining a deployment contract process container unit creation template;
and the creating unit is used for operating the deployment contract process container unit template through the container unit creator to create the first contract process container unit.
Wherein the contract deployment transaction comprises transaction initiation object information;
the above data processing apparatus further includes:
the right verification module is used for carrying out deployment right verification processing according to the transaction initiating object information in the contract dispatcher container unit to obtain a deployment right verification result;
The right verification module is further used for calling the creation module to execute the step of creating the first contract process container unit according to contract deployment transaction if the deployment right verification result is the deployment right verification passing result;
and the permission verification module is also used for sending permission verification failing prompt information to the blockchain node if the deployment permission verification result is the deployment permission verification failing result.
Wherein the container cluster management node further comprises a contract auditing container unit;
the above data processing apparatus further includes:
the contract auditing module is used for acquiring intelligent contract codes from contract deployment transactions through the contract dispatcher container unit and sending the intelligent contract codes to the contract auditing container unit;
the contract auditing module is also used for carrying out code security verification processing on the intelligent contract code in the contract auditing container unit to obtain a security verification result, and sending the security verification result to the contract dispatcher container unit;
the contract auditing module is also used for calling the creating module to execute the step of creating a first contract process container unit according to contract deployment transaction in the contract dispatcher container unit if the security verification result is a security verification passing result;
And the contract auditing module is also used for sending a security verification failing prompt message to the blockchain node through the contract dispatcher container unit if the security verification result is the security verification failing result.
Wherein the contract deployment transaction further includes a first horizontal scaling parameter; the container cluster management node also comprises a horizontal expansion and contraction component;
the above data processing apparatus further includes:
the system comprises a contract dispatcher container unit, a contract dispatcher, a first contract identification module and a second contract identification module, wherein the contract dispatcher container unit is used for receiving a second contract identification; the horizontal expansion and contraction object corresponding to the second contract identification is used for indicating the horizontal expansion and contraction component to adjust the quantity of contract process copy container units corresponding to the first contract process container units according to the average computing power resource occupation information corresponding to the second contract identification and the first horizontal expansion and contraction parameter; the contract process copy container unit is created by the horizontal expansion and contraction component according to the first contract process container unit; the first contract process container unit and the contract process copy container unit corresponding to the first contract process container unit form a contract process container unit set, and the second contract identifies one or more associated contract process container units.
Wherein the container cluster management node further comprises a horizontal expansion and contraction component; the contract process container unit set comprises M contract process container units associated with a third contract identification; the M contract process container units comprise second contract process container units and M-1 contract process copy container units, wherein M is a positive integer; m-1 contract process copy container units are all created by the horizontal expansion and contraction component according to a second contract process container unit; the M contract process container units are all deployed with a third intelligent contract corresponding to a third contract identifier;
the above data processing apparatus further includes:
the information acquisition module is used for acquiring average computing power resource occupation information corresponding to the third contract identification through the horizontal expansion and contraction component; the average computing power resource occupation information is obtained by carrying out average processing according to computing power resource occupation information respectively corresponding to M contract process container units;
the parameter acquisition module is used for acquiring a second horizontal expansion and contraction parameter corresponding to the third contract identifier;
and the horizontal expansion and contraction module is used for carrying out horizontal expansion and contraction processing on the M contract process container units according to the average computing power resource occupation information and the second horizontal expansion and contraction parameters.
Wherein the second horizontal expansion and contraction parameter comprises a maximum occupation threshold value of computing power resources and a maximum number of container units;
a horizontal expansion and contraction module, comprising:
the expansion quantity determining unit is used for determining the quantity of the pre-expansion copy container units according to M, the maximum occupation threshold of the computing power resources, the maximum quantity of the container units and the average computing power occupation information if the average computing power resource occupation information exceeds the maximum occupation threshold of the computing power resources; the sum of M and the number of pre-expanded replica container units is less than or equal to the maximum number of container units;
the expansion unit is used for creating expansion contract process copy container units corresponding to the number of the pre-expansion copy container units according to the second contract process container units, adding the expansion contract process copy container units to the contract process container unit set, and sending the association relation between the expansion contract process copy container units and the third contract identification to the traffic load balancer.
Wherein the expansion number determining unit includes:
the coefficient determining subunit is used for determining the ratio of the average computing power occupation information to the maximum occupation threshold value of the computing power resource as an adjustment coefficient;
the calculation subunit is used for multiplying the adjustment coefficient by M to perform rounding treatment to obtain the total adjustment quantity;
The calculating subunit is further configured to determine, if the total number of adjustments is less than or equal to the maximum number of container units, a difference between the total number of adjustments and M as the number of pre-expanded duplicate container units;
and the calculating subunit is further configured to determine, as the number of pre-expanded copy container units, a difference between the maximum number of container units and M if the total number of adjustments is greater than the maximum number of container units.
Wherein the second horizontal expansion and contraction parameter comprises a minimum occupation threshold value of computing power resources and a minimum number of container units;
a horizontal expansion and contraction module, comprising:
the reduced number determining unit is used for determining the number of the pre-reduced copy container units according to M, the minimum occupation threshold of the computing power resources, the minimum number of the container units and the average computing power occupation information if the average computing power resource occupation information is smaller than the minimum occupation threshold of the computing power resources; the difference between M and the number of pre-reduced replica container units is greater than or equal to the minimum number of container units;
the reducing unit is used for selecting contract process copy container units corresponding to the number of the pre-reduced contract process copy container units from M-1 contract process copy container units as contract process copy container units to be reduced;
and the reduction unit is further used for deleting the to-be-reduced contract process copy container unit when the to-be-reduced contract process copy container unit is determined to be in an idle condition, and deleting the association relation between the to-be-reduced contract process copy container unit and the third contract identification in the transaction load balancer.
Wherein the contract dispatcher container unit further comprises a container unit destroyer; the contract process container unit comprises N contract process container units associated with a fourth contract identifier, wherein N is a positive integer;
the above data processing apparatus further includes:
the call acquisition module is used for acquiring the call condition of the fourth intelligent contract corresponding to the fourth contract identifier in the target time period;
and the emptying module is used for emptying the N contract process container units associated with the fourth contract identification through the container unit destructor if the calling condition indicates that the fourth intelligent contract meets the task-free calling condition.
In one aspect, an embodiment of the present application provides a computer device, including: a processor, a memory, a network interface;
the processor is connected to the memory and the network interface, where the network interface is used to provide a data communication network element, the memory is used to store a computer program, and the processor is used to call the computer program to execute the method in the embodiment of the present application.
In one aspect, embodiments of the present application provide a computer readable storage medium having a computer program stored therein, the computer program being adapted to be loaded by a processor and to perform a method according to embodiments of the present application.
In one aspect, embodiments of the present application provide a computer program product or computer program comprising computer instructions stored in a computer-readable storage medium, the computer instructions being read from the computer-readable storage medium by a processor of a computer device, the computer instructions being executed by the processor, causing the computer device to perform a method according to an embodiment of the present application.
In the embodiment of the application, each blockchain node in the blockchain network can be correspondingly provided with a container cluster management node, the container cluster management node can comprise a contract dispatcher container unit, a transaction load balancer and a contract process container unit set, and the container cluster management node can receive a business transaction comprising a first contract identifier of a first intelligent contract and sent by the blockchain node through the contract dispatcher container unit and forward the business transaction to the transaction load balancer; then, in the transaction load balancer, acquiring one or more contract process container units associated with the first contract identification from the contract process container unit set, and then selecting a contract process container unit meeting idle scheduling conditions from the one or more contract process container units as a target contract process container unit; wherein the first intelligent contract is deployed in one or more contract process container units; and finally, the business transaction can be sent to a target contract process container unit through a transaction load balancer, the first intelligent contract is called in the target contract process container unit to execute the business transaction, a transaction execution result is obtained, and the transaction execution result is sent to the blockchain node. According to the method provided by the embodiment of the application, intelligent contracts in the blockchain are deployed in different contract process container units, mutual interference between contract processes corresponding to different intelligent contracts can be avoided due to isolation among the contract process container units, in addition, the same intelligent contract can be deployed in a plurality of contract process container units, when a plurality of transactions call the same intelligent contract in the same time period, dynamic allocation of resources can be realized through a transaction load equalizer, namely, the transactions are sent to idle contract process container units, resource disputes among a plurality of contract processes corresponding to the same intelligent contract are reduced, and the contract execution efficiency is improved.
Drawings
In order to more clearly illustrate the embodiments of the application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic diagram of a network architecture according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a block chain based data processing method according to an embodiment of the present application;
FIG. 3 is a flowchart of a block chain based data processing method according to an embodiment of the present application;
FIG. 4 is a flow chart of another block chain based data processing method according to an embodiment of the present application;
FIG. 5 is a flow chart of yet another block chain based data processing method according to an embodiment of the present application;
FIG. 6 is a diagram of a blockchain-based contract engine namespace, provided in accordance with embodiments of the present application;
FIG. 7 is a flow diagram of smart contract deployment provided by an embodiment of the present application;
FIG. 8 is a flow diagram of intelligent contract invocation, provided by an embodiment of the present application;
FIG. 9 is a flow chart illustrating the dynamic expansion of a contract process container unit provided by an embodiment of the application;
FIG. 10 is a block chain based data processing apparatus according to an embodiment of the present application;
fig. 11 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
For ease of understanding, the following simple explanation of partial nouns is first made:
1. blockchain (Block chain): in a narrow sense, the blockchain is a chain data structure taking a block as a basic unit, and the block uses a digital abstract to verify the transaction history acquired before, so that the blockchain 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 structures, including distributed consensus, privacy and security protection, point-to-point communication techniques, network protocols, smart contracts, and the like.
The goal of the blockchain is to implement a distributed data logging ledger that allows only additions and not deletions. The basic structure of the ledger floor is a linear linked list. The linked list is formed by serially connecting blocks, the Hash value of the preceding block is recorded in the following blocks, and whether each block (and the transaction in the block) is legal or not can be rapidly checked by calculating the Hash value. If a node in the network proposes to add a new block, a consensus acknowledgement must be made for the block via a consensus mechanism.
2. Block (block): the data packet carrying transaction data on the blockchain network is a data structure marked with a timestamp and a hash value corresponding to a preceding block, and the block verifies and confirms the transaction in the block through a consensus mechanism of the network. The Block includes a Block Header (Block Header) and a Block Body (Block Body), where the Block Header can record meta information of the current Block and includes data such as a current version number, a hash value corresponding to a previous Block, a timestamp, a random number, a hash value of a Merkle Root (Merkle Root), and the like. The block may record detailed data generated over a period of time, including all transaction records or other information generated during the creation of the block for which the current block is verified, and may be understood as a representation of the ledger. In addition, the detailed data of the block may include generating a unique Merkle Root record in the block header through a hash process of a Merkle Tree (Merkle Tree).
The successor Block, also called Parent Block (Parent Block), is a Block chain that performs temporal ordering by recording the hash value corresponding to the Block and the hash value corresponding to the Parent Block in the Block header.
3. Hash value (hash): also called information characteristic value or eigenvalue, hash value is generated by converting input data of arbitrary length into a password by hash algorithm and performing fixed output, 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 initial block) contains a hash value of the successor block, which is the potential core foundation and most important aspect in blockchain technology, which preserves the authenticity of the recorded and viewed data, as well as the integrity of the blockchain as a whole.
4. Smart Contract: an intelligent contract is a computer protocol that aims to propagate, verify, or execute contracts in an informative manner. The concept of intelligent contracts has three major elements of commitment, agreement and digital form, so that the application range of the blockchain can be expanded to all links of transaction, payment, settlement and clearing in the financial industry. Intelligent contracts refer to the immediate execution of corresponding contract terms when a pre-programmed condition is triggered, the working principle of which is similar to the if-then statement of a computer program. Smart contracts allow trusted transactions to be made without third parties, which transactions are traceable and irreversible.
5. Kubernetes (container cluster management system): kubernetes (which may be referred to simply as k8 s) is an open-source container orchestration platform for automated deployment, extension, and management of containerized applications. It provides a portable, extensible, self-healing operating environment that can operate in public, private and hybrid clouds. The Kubernetes can manage a plurality of containerized application programs, provide functions of load balancing, automatic telescoping, automatic recovery and the like, and enable deployment and management of the containerized application programs to be simpler and more efficient.
6. HPA (horizontal expansion/contraction): kubernetes HPA (Horizontal Pod Autoscaler) is an automated mechanism that dynamically adjusts the number of copies of an application to maintain the availability and performance of the application in response to changes in the load of the application. The HPA may obtain the CPU (Central Processing Unit ) usage, memory usage, or custom metrics of the container in real time, and automatically expand or contract the number of copies of the application as needed to meet the load demand. For example, when the CPU utilization of the container exceeds a preset threshold, the HPA may automatically increase the number of copies of the application to increase the processing power of the application. Conversely, when the CPU utilization of the container drops, the HPA may automatically reduce the number of copies of the application to save resources and costs.
7. pod (container unit): pod of Kubernetes is the smallest deployable unit in Kubernetes, which is a collection of one or more containers that share network and storage resources and run on the same node. Pod is a basic building block of an application in Kubernetes, and may contain one or more containers that may cooperate to run the application or service. Containers in Pod may share the same network namespace, so that localhost communication may be used, or the same storage volume may be shared, so that data is shared. Pod can also be viewed as a logical host, which may have its own IP (Internet Protocol ) address and port, can communicate internally between containers, and can be exposed to external access through Kubernetes Service (service). Pod is an important concept in Kubernetes, which provides a flexible way to organize and deploy containerized applications while also allowing resource restriction and isolation of containers, thereby improving the reliability and security of the applications.
Referring to fig. 1, fig. 1 is a schematic diagram of a network architecture according to an embodiment of the present application.
The blockchain network as shown in fig. 1 may include, but is not limited to, a blockchain network to which the federated chain corresponds. The blockchain network may include a plurality of blockchain nodes, and the plurality of blockchain nodes may include a blockchain node 10a, a blockchain node 10b, a blockchain node 10c, a blockchain node 10d, …, and a blockchain node 10n. Each blockchain node can receive data sent by the outside during normal operation, perform blockchain uplink processing based on the received data, and also can send the data to the outside. To ensure data interworking between the various blockchain nodes, a data connection may exist between each blockchain node, such as between blockchain node 10a and blockchain node 10b, between blockchain node 10a and blockchain node 10c, and between blockchain node 10b and blockchain node 10 c.
It will be appreciated that data, transactions or block transfers may be made between blockchain nodes through the data connections described above. The blockchain network may implement data connection between blockchain nodes based on node identifiers, and for each blockchain node in the blockchain network, each blockchain node may store node identifiers of other blockchain nodes having a connection relationship with itself, so as to broadcast the acquired data or generated blocks to other blockchain nodes according to the node identifiers of the other blockchain nodes, for example, the blockchain node 10a may maintain a node identifier list as shown in table 1, where the node identifier list stores node names and node identifiers of the other nodes:
TABLE 1
The node identifier may be any of a protocol (Internet Protocol, IP) address for interconnection between networks, and any other information that can be used to identify a node in a blockchain network, and the IP address is only illustrated in table 1. For example, the blockchain node 10a may send information (e.g., a block) to the blockchain node 10b through the node identification bbb.bbb.bbb.bbb.bbb, and the blockchain node 10b may determine that the information was sent by the blockchain node 10a through the node identification aaa.aaa.aaa.
In a blockchain, a block must be consensus-passed through consensus nodes in the blockchain network before the block is uplink, and the block can be added to the blockchain after the consensus passes. It will be appreciated that when a blockchain is used in some contexts of a government or commercial establishment, not all participating nodes in the blockchain (i.e., blockchain nodes in the blockchain network described above) have sufficient resources and necessity to become consensus nodes of the blockchain. For example, in the blockchain network shown in fig. 1, blockchain node 10a, blockchain node 10b, blockchain node 10c, and blockchain node 10d may be considered as consensus nodes in the blockchain network. The consensus nodes in the blockchain network participate in consensus, namely, consensus is carried out on the blocks (comprising a batch of transactions), namely, voting is carried out on the blocks; while non-consensus nodes do not participate in consensus, but will help propagate block and vote messages, and synchronize status with each other, etc.
In the blockchain network shown in fig. 1, each blockchain node may correspond to a container cluster management node, e.g., blockchain node 10a may correspond to container cluster management node 100a, blockchain node 10b may correspond to container cluster management nodes 100b, …, and blockchain node 10n may correspond to container cluster management node 100n. The container cluster management node refers to a node integrated with a container cluster management system (i.e., k8 s), and a data connection exists between each blockchain node and its corresponding container cluster management node, for example, a data connection exists between the blockchain node 10c and the container cluster management node 100 c. The block chain link points and the corresponding container cluster management nodes can transmit data and transaction through the data connection. It should be understood that the above data connection is not limited to a connection manner, and may be directly or indirectly connected through a wired communication manner, may be directly or indirectly connected through a wireless communication manner, or may be connected through other connection manners, which is not limited herein.
It is to be appreciated that the container cluster management node is configured to deploy intelligent contracts in a blockchain network, and the container cluster management node may include a contract dispatcher container unit, a transaction load balancer, and a contract process container unit set, where the contract process container unit set may include one or more contract process container units, each of which has an intelligent contract deployed therein. In the application, when the blockchain node receives the business transaction requiring to call the first intelligent contract, the business transaction can be sent to the contract process container unit which is contained in the container cluster management node and is deployed with the first intelligent contract for execution, and because of the isolation between different contract process container units, resource disputes with the call of other contracts can be avoided, and the contract execution efficiency is improved.
Specifically, in the present application, a container cluster management node may receive, through a contract dispatcher container unit, a service transaction sent by a blockchain node, and then forward the service transaction to a transaction load balancer, where the service transaction may include a first contract identifier corresponding to a first intelligent contract, then may acquire, in the transaction load balancer, one or more contract process container units associated with the first contract identifier from a contract process container unit set, select, as a target contract process container unit, a contract process container unit meeting idle dispatch conditions from the one or more contract process container units, where it may be understood that the acquired one or more contract process container units are each deployed with the first intelligent contract, and finally send, through the transaction load balancer, the service transaction to the target contract process container unit, call the first intelligent contract to execute the service transaction in the target contract process container unit, obtain a transaction execution result, and send the transaction execution result to the blockchain node. After receiving the transaction execution result, the block chain link point can package the transaction execution result into a block and then send the block into other block chain nodes for consensus, and after the consensus is passed, the transaction execution result is written into a block chain account book.
It will be appreciated that the data processing method provided by the embodiment of the present application may be performed by a computer device, including but not limited to the container cluster management node (which may be a terminal or a server) described above. The 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 cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs, basic cloud computing services such as big data and artificial intelligence platforms. The terminal may be, but is not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, etc.
It is to be appreciated that embodiments of the present application may be applied to a variety of scenarios including, but not limited to, cloud technology, artificial intelligence, intelligent transportation, etc. For example, the block link point system may perform consensus on some driving behavior data, road track data, and the like sent by the vehicle-mounted terminal, and store the consensus on the vehicle-mounted terminal after the consensus passes.
It will be appreciated that in the specific embodiments of the present application, related data such as transaction data, status data, etc. are involved, and when the above embodiments of the present application are applied to specific products or technologies, user permissions or consents are required, and the collection, use and processing of related data is required to comply with the relevant laws and regulations and standards of the relevant region.
In order to facilitate understanding of the foregoing smart contract invoking process, please refer to fig. 2, fig. 2 is a schematic diagram of a scenario of a blockchain-based data processing method according to an embodiment of the present application. The blockchain node 20 shown in fig. 2 may be any blockchain node in the blockchain network shown in fig. 1, e.g., the blockchain node 20 may be the blockchain node 10b; at this time, the container cluster management node 22 shown in fig. 2 may be the container cluster management node 100b corresponding to the blockchain node 10b shown in fig. 1 described above.
As shown in fig. 2, after receiving the business transaction 21 carrying the contract a identifier, the blockchain node 20 needs to invoke the contract a corresponding to the contract a identifier to execute the business transaction 21, and the blockchain node 20 sends the business transaction 21 to the contract dispatcher container unit 221 included in the container cluster management node 22, and the container cluster management node 22 sends the business transaction 21 to the transaction load balancer 222 through the contract dispatcher container unit 221, and then, in the transaction load balancer 222, obtains the contract process container unit associated with the contract a identifier from the contract process container unit set included in the container cluster management node 22, for example, the contract process container unit 223, the contract process container unit 224 and the contract process container unit 225, where the contract process container unit 223, the contract process container unit 224 and the contract process container unit 225 are all disposed with the contract a corresponding to the contract a identifier. The transaction load balancer 222 may then select a contract process container unit that meets idle schedule conditions from the contract process container units associated with the contract A identification as the target contract process container unit. The selecting a contract process container unit meeting the idle scheduling condition may be selecting a contract process container unit with a computing power resource occupancy rate lower than an occupancy threshold, or selecting a contract process container unit with a lowest computing power resource occupancy rate from contract process container units associated with a contract a identifier, or performing other settings according to actual situations, which is not limited in this application. The computing power resource may be one or more resources of system resources such as cpu resources and memory resources.
Assuming that the container cluster management node 22 determines, through the transaction load balancer 222, that the contract process container unit 224 is a contract process container unit that meets the space scheduling condition, as shown in fig. 2, the container cluster management node 22 sends the business transaction 21 to the contract process container unit 224 through the transaction load balancer 222, then calls the contract a to execute the business transaction 21 in the contract process container unit 224 to obtain a transaction execution result, and then the container cluster management node 22 sends the transaction execution result to the blockchain node 20.
Optionally, after receiving the transaction execution result corresponding to the service transaction 21, the blockchain node 20 may package the service transaction 21 and the transaction execution result to form a block, then send the block to other blockchain link points in the blockchain network for consensus, and after the consensus passes, write the service transaction 21 and the transaction execution result into the blockchain ledger.
It can be understood that the intelligent contracts in the blockchain are deployed in different contract process container units, and because of isolation between the contract process container units, mutual interference between contract processes corresponding to different intelligent contracts can be avoided.
Further, referring to fig. 3, fig. 3 is a flowchart of a data processing method based on a blockchain according to an embodiment of the present application. Wherein the blockchain network comprises blockchain nodes and container cluster management nodes corresponding to the blockchain link nodes; the container cluster management node comprises a contract dispatcher container unit, a transaction load balancer and a contract process container unit set; wherein the method may be performed by a container cluster management node (e.g., container cluster management node 100a in the embodiment described above with respect to fig. 1). The following will describe an example of the method performed by the container cluster management node, where the blockchain-based data processing method may at least include the following steps S101 to S103:
step S101, receiving a business transaction sent by a blockchain node through a contract dispatcher container unit, and forwarding the business transaction to a transaction load balancer; the business transaction includes a first contract identification corresponding to the first intelligent contract.
Specifically, the container cluster management node refers to a node integrated with Kubernetes (hereinafter referred to as k8s for short), and in practical application, the container cluster management node may include a master server and a plurality of node (service) servers, where the master server is responsible for scheduling, managing and operating the k8s cluster, and the node server is an operation workload server in the k8s cluster. Pod is the smallest deployable unit in k8s, which is a combination of one or more containers, and a node server may be used to host the operation of the Pod (container unit) to carry the operation of the allocated Pod or pods. It will be appreciated that there is isolation between the different pod. The container units mentioned in the present application may be deployed in different node servers, or may be deployed in the same node server, where the present application is not limited thereto, and alternatively, functions provided by a master (management) server and a node (service) server may be integrated in the same server, where the present application is not limited thereto.
Specifically, the contract dispatcher container unit is used for scheduling all tasks requiring to invoke business transactions of the intelligent contract, wherein the intelligent contract is not deployed, but the contract file or the contract code of the intelligent contract deployed in the container cluster management node can be stored in the contract dispatcher container unit for reservation. It will be appreciated that the pod in k8s can be considered a logical host with its own IP address and port, and thus the blockchain node can send traffic directly to the contract scheduler container unit in the container cluster management node. The contract dispatcher container unit may include a network module therein that is responsible for receiving business transactions from the blockchain or contract deployment transactions for deploying the smart contracts.
Specifically, after the contract dispatcher container unit determines that the received transaction is a business transaction requiring the invocation of an intelligent contract, the business transaction can be forwarded to a transaction load balancer. Wherein the transaction load balancer is an application component deployed in a container cluster management node for responsible for distributing business transactions to appropriate contractual process container units.
Step S102, in the transaction load balancer, acquiring one or more contract process container units associated with the first contract identification from a contract process container unit set, and selecting a contract process container unit meeting idle scheduling conditions from the one or more contract process container units as a target contract process container unit; the first smart contract is deployed in each of the one or more contract process container units.
Specifically, the contract process container unit set includes all contract process container units in the container cluster management node, wherein the contract process container units are container units for actually executing contract tasks, and can continuously run contract processes for executing the contract tasks. Different smart contracts are deployed in different contract process container units, and for some hot smart contracts, the same smart contract can be deployed in multiple contract process container units at the same time. When a plurality of business transactions needing to call the same intelligent contract need to be executed, the business transactions can be distributed to different contract process container units deployed with the intelligent contract through a transaction load balancer, so that the contention of calculation resources among contract processes is avoided.
Specifically, in the transaction load balancer, one or more contract process container units associated with the first contract identifier are obtained from the contract process container unit set, and a contract process container unit meeting idle scheduling conditions is selected from the one or more contract process container units, and as a feasible implementation procedure of the target contract process container unit, the method may be as follows: in a transaction load balancer, acquiring one or more contract process container units associated with a first contract identifier from a contract process container unit set, then acquiring computing power resource occupation information corresponding to the one or more contract process container units associated with the first contract identifier, and determining the contract process container unit with the smallest computing power resource occupation information as a contract process container unit conforming to idle scheduling conditions; and taking the contract process container unit meeting the idle scheduling condition as a target contract process container unit. The computing power resource occupation information may include occupation information of one or more computing power resources such as cpu resources and memory resources, for example, the computing power resource occupation information may include cpu resource occupation rate.
Step S103, the business transaction is sent to the target contract process container unit through the transaction load balancer, the first intelligent contract is called to execute the business transaction in the target contract process container unit, a transaction execution result is obtained, and the transaction execution result is sent to the blockchain node.
Specifically, after determining the target contract process container unit, the transaction load balancer may send the business transaction to the target contract process container unit, and then the container cluster management node may call the first intelligent contract to execute the business transaction in the target contract process container unit to obtain a transaction execution result, and send the transaction execution result to the blockchain node.
Optionally, after receiving the transaction execution result, the blockchain node may package the business transaction and the transaction execution result into a block, and then send the block into other blockchain nodes in the blockchain network for consensus, and if the consensus passes, write the business transaction and the transaction execution result into the blockchain ledger. It can be understood that when the other blockchain nodes perform consensus on the block, the correctness of the transaction execution result needs to be verified, and the other blockchain nodes can send the service transaction to the corresponding container cluster management node for execution, and the execution process can refer to the above steps S101-S103, which are not described herein. If other blockchain nodes determine that the transaction execution result returned by the corresponding container cluster management node is the same as the transaction execution result contained in the block, the other blockchain nodes can cast out an approval ticket supporting the passing of the consensus.
According to the method provided by the embodiment of the application, intelligent contracts in the blockchain are deployed in different contract process container units, mutual interference between contract processes corresponding to different intelligent contracts can be avoided due to isolation among the contract process container units, in addition, the same intelligent contract can be deployed in a plurality of contract process container units, when a plurality of transactions call the same intelligent contract in the same time period, dynamic allocation of resources can be realized through a transaction load equalizer, namely, the transactions are sent to idle contract process container units, resource disputes among a plurality of contract processes corresponding to the same intelligent contract are reduced, and the contract execution efficiency is improved.
Further, referring to fig. 4, fig. 4 is a flowchart illustrating another data processing method based on blockchain according to an embodiment of the present application. Wherein the blockchain network comprises blockchain nodes and container cluster management nodes corresponding to the blockchain link nodes; the container cluster management node comprises a contract dispatcher container unit, a transaction load balancer and a contract process container unit set; wherein the method may be performed by a container cluster management node (e.g., container cluster management node 100a in the embodiment described above with respect to fig. 1). The following description will be given by taking the embodiment of the present method as an example, where the blockchain-based data processing method may at least include the following steps S201 to S204:
Step S201, receiving a contract deployment transaction sent by a blockchain node through a contract dispatcher container unit; the contract deployment transaction includes a second contract identification corresponding to the second smart contract and a smart contract code.
Specifically, a contract manager of the blockchain wants to deploy a second intelligent contract in the blockchain network, a contract deployment transaction including a second contract identifier corresponding to the second intelligent contract and an intelligent contract code can be initiated to a blockchain link point, the blockchain link point checks the validity of the contract deployment transaction, the contract deployment transaction can be sent to a contract dispatcher container unit in a container cluster management node, and then the container cluster management node can create a contract process container unit deployed with the second intelligent contract through the contract dispatcher container unit.
Optionally, before creating the contract process container unit containing the second smart contract, authority verification may be performed on the identity of the transaction initiating object, so as to avoid that personnel without deployment authority may optionally deploy the smart contract in the blockchain network. Therefore, in the contract deployment transaction, transaction initiation object information can be contained, and at the moment, the container cluster management node can perform deployment permission verification processing in a contract dispatcher container unit according to the transaction initiation object information to obtain a deployment permission verification result; if the deployment right verification result is the deployment right verification passing result, executing step S202; if the deployment permission verification result is a deployment permission verification failing result, sending permission verification failing prompt information to the blockchain node. The deployment permission verification process is performed according to the transaction initiating object information, and a feasible implementation process of the deployment permission verification result is obtained, which may be: searching a right object list, and if the transaction initiation object information is searched in the right object list, determining that the deployment right verification result is a deployment right verification passing result; if the transaction initiation object information is not found in the rights object list, determining that the deployment rights verification result is a deployment rights verification failure result. Wherein the rights object list contains object information having deployment rights.
Optionally, before creating the contract process container unit including the second smart contract, the security of the smart contract may be audited, so as to avoid the transaction failure or unsafe problem caused by the code bug of the smart contract. The container cluster management node can also comprise a contract auditing container unit, and can acquire an intelligent contract code from a contract deployment transaction through a contract dispatcher container unit and send the intelligent contract code to the contract auditing container unit; in the contract auditing container unit, performing code security verification processing on the intelligent contract code to obtain a security verification result, and sending the security verification result to the contract dispatcher container unit; if the security verification result is a security verification passing result, executing step S202 in the contract dispatcher container unit; if the security verification result is a security verification failure result, sending a security verification failure prompt message to the blockchain node through the contract dispatcher container unit. The code security verification process may be to perform security verification on the logic, grammar and other issues of the intelligent contract code, so as to ensure the security of the intelligent contract code.
Step S202, creating a first contract process container unit according to the contract deployment transaction; the first contract process container unit contains the intelligent contract code.
Specifically, the contract dispatcher container unit may include an initial contract process container unit creation template and a container unit creator, and one possible implementation procedure for creating the first contract process container unit according to the contract deployment transaction may be: in a contract dispatcher container unit, acquiring an initial contract process container unit creation template, and updating the initial contract process container unit creation template according to an intelligent contract code to obtain a deployment contract process container unit creation template; a first contract process container unit is created by the container unit creator running a deployment contract process container unit template. Wherein the initial contract process container unit creation template may be a file configured in advance for creating the contract process container unit. The method comprises the steps of updating an initial contract process container unit creation template according to intelligent contract codes, namely writing intelligent contract codes corresponding to a second intelligent contract into contract related parts in the initial contract process container unit creation template, and obtaining a deployment contract process container unit creation template. After running the deployment contract process container unit creation template, the container cluster management node may create a first contract process container unit containing the smart contract code of the second smart contract.
Step S203, transmitting the association relationship between the contract deployment transaction and the second contract identifier and the first contract process container unit to a transaction load balancer; in the transaction load balancer, forwarding the contract deployment transaction to the first contract process container unit according to the association relationship between the second contract identification and the first contract process container unit.
Specifically, after the first contract process container unit is created, the contract initialization is required, so that the contract deployment transaction is also required to be sent to the first contract process container unit, and relay forwarding of the contract deployment transaction can be performed through the transaction load balancer. In addition, the container cluster management node records the association relation between the second contract identification and the first contract process container unit in the transaction load balancer, so that when the business transaction calling the second intelligent contract exists later, the business transaction is sent to the first contract process container unit according to the association relation in the transaction load balancer.
Step S204, in the first contract process container unit, calling the intelligent contract code to perform contract initialization processing according to the contract deployment transaction to obtain a contract initialization result, and sending the contract initialization result to the blockchain node; the contract initialization result is used for representing deployment conditions of the second intelligent contract in the first contract process container unit.
Specifically, the contract deployment transaction may further include a contract initialization request for calling an initialization method in the second intelligent contract, and the container cluster management node may call the initialization method in the second intelligent contract according to the contract initialization request in the first contract process container unit, and then execute the initialization method to perform contract initialization processing, so as to obtain a contract initialization result. The contract initialization result may include a contract initialization success result and a contract initialization failure result, where the contract initialization success result is used to indicate that the second intelligent contract deployment is successful, and the contract initialization failure result is used to indicate that the second intelligent contract deployment fails.
Optionally, the contract deployment transaction may include a first horizontal expansion parameter; the container cluster management node also comprises a horizontal expansion and contraction component; the container cluster management node may create, in the contract dispatcher container unit, a corresponding horizontal scaling object for the second contract identification from the first horizontal scaling parameter. Wherein the horizontal scaling component may be an HPA in a k8s cluster. The second contract identification corresponds to a horizontal expansion and contraction object and is used for indicating the horizontal expansion and contraction component to adjust the quantity of contract process copy container units corresponding to the first contract process container units according to average computing power resource occupation information corresponding to the second contract identification and the first horizontal expansion and contraction parameter; the contract process copy container unit is created by the horizontal expansion and contraction component according to the first contract process container unit; the first contract process container unit and the contract process copy container unit corresponding to the first contract process container unit form a contract process container unit set, and the second contract identifies one or more associated contract process container units. The average computing power resource occupation information corresponding to the second contract identifier refers to an average value of computing power resource occupation information corresponding to one or more contract process container units associated with the second contract identifier, that is, an average value of computing power resource occupation information corresponding to the first contract process container unit and the contract process copy container unit corresponding to the first contract process container unit.
That is, after creating the horizontal scaling object corresponding to the second contract identifier, the container cluster management node may dynamically create or delete, during the operation of the one or more contract process container units associated with the second contract identifier, a contract process copy container unit corresponding to the first contract process container unit through the horizontal scaling component, for example, the average computing power resource usage information is cpu average usage is 60%, the first horizontal scaling parameter includes an expansion parameter of 50% and a reduction parameter of 20%, because the average computing power resource usage information is greater than the expansion parameter, and at this time, the container cluster management node may dynamically create, through the horizontal scaling component, one or more contract process copy container units corresponding to the first contract process container unit to reduce the computing power resource pressure of the existing contract process container unit. The specific implementation process of creating or deleting the container unit of the about process copy according to the horizontal expansion and contraction component can be referred to as the description in the embodiment corresponding to fig. 5 below.
By adopting the method provided by the embodiment of the application, the intelligent contracts in the block chain are deployed in different contract process container units, and the problem of resource disputes during intelligent contract calling can be avoided because of isolation among the contract process container units. Optionally, in order to avoid that the intelligent contract is optionally deployed, the container cluster management node may further perform authority verification on a transaction initiation object corresponding to the contract deployment transaction before responding to the contract deployment transaction, and only the contract deployment transaction passing the authority verification may be responded. Optionally, in order to avoid that the environmental stability is affected by the leaky contracts, a contract auditing container unit may be added, and before responding to the contract deployment transaction, the container cluster management node needs to audit the contract deployment transaction by applying for the container unit through the contracts, so as to avoid that unsafe contracts affect the system environment.
Further, referring to fig. 5, fig. 5 is a flowchart of another data processing method based on blockchain according to an embodiment of the present application. Wherein the blockchain network comprises blockchain nodes and container cluster management nodes corresponding to the blockchain link nodes; the container cluster management node comprises a contract dispatcher container unit, a transaction load balancer and a contract process container unit set; wherein the method may be performed by a container cluster management node (e.g., container cluster management node 100a in the embodiment described above with respect to fig. 1). The following description will be given by taking the embodiment of the present method as an example, where the blockchain-based data processing method may at least include the following steps S301 to S302:
step S301, obtaining average computing power resource occupation information corresponding to the third contract identification through the horizontal expansion and contraction component.
Specifically, the average computing power resource occupation information is obtained by performing average processing according to computing power resource occupation information corresponding to the M contract process container units respectively. Wherein M is a positive integer; m contract process container units are contract process container units in the contract process container unit set which are associated with a third contract identification, the M contract process container units comprise a second contract process container unit and M-1 contract process copy container units, and the M-1 contract process copy container units are all created by the horizontal expansion and contraction component according to the second contract process container unit, namely, the M-1 contract process copy container units are all copies of the second contract process container unit. It will be appreciated that the M contract process container units, that is, the second contract process container unit and the M-1 contract process replica container units, each have disposed therein a third smart contract corresponding to a third contract identification.
Specifically, each contract process container unit includes a resource detection component, when the contract process container unit runs, the container cluster management node can acquire computing power resource occupation information of the contract process container unit in real time through the resource detection component, then the computing power resource occupation information is sent from the contract process container unit to an interface service (namely an API server in a k8s cluster), and then the interface service forwards the computing power resource occupation information to the horizontal expansion and contraction component. After receiving the computing power resource occupation information of the M contract process container units, the horizontal expansion and contraction component can perform average processing on the computing power resource occupation information, so that average computing power resource occupation information is obtained.
Step S302, obtaining a second horizontal expansion and contraction parameter corresponding to the third contract identifier, and performing horizontal expansion and contraction processing on M contract process container units according to the average computing power resource occupation information and the second horizontal expansion and contraction parameter.
Specifically, the horizontal expansion and contraction parameter corresponding to each contract identifier may be set when the horizontal expansion and contraction object is created for the contract identifier, and specific setting values and setting parameter types may be adjusted based on actual situations, which is not limited herein.
Specifically, the second horizontal expansion and contraction parameter may include a maximum occupation threshold of computing power resources and a maximum number of container units, and one possible implementation process of performing horizontal expansion and contraction processing on the M contract process container units according to the average computing power resource occupation information and the second horizontal expansion and contraction parameter may be: if the average computing power resource occupation information exceeds the computing power resource maximum occupation threshold, determining the number of the pre-expanded copy container units according to M, the computing power resource maximum occupation threshold and the average computing power occupation information; the sum of M and the number of pre-expanded replica container units is less than or equal to the maximum number of container units; creating extension contract process copy container units corresponding to the number of the pre-extension copy container units according to the second contract process container units, adding the extension contract process copy container units to a contract process container unit set, and sending the association relation between the extension contract process copy container units and the third contract identification to a traffic load balancer. One possible implementation process for determining the number of pre-expanded copy container units according to the M, the maximum occupation threshold of computing power resources, and the average computing power occupation information may be: determining the ratio of the average computing power occupation information to the maximum computing power resource occupation threshold value as an adjustment coefficient; multiplying the adjustment coefficient by M to obtain an adjustment total number; if the total adjustment quantity is smaller than or equal to the maximum quantity of container units, determining the difference value between the total adjustment quantity and M as the quantity of the pre-expansion copy container units; if the total number of adjustment is larger than the maximum number of container units, determining the difference value between the maximum number of container units and M as the number of pre-expansion copy container units. The multiplication rounding process refers to rounding up the product of multiplication, for example, the product is 2.1, and the rounding up is 3. In order to facilitate understanding the above process, assuming that the maximum occupation threshold of the computing power resource is 0.6, the maximum number of container units is 6, and the average computing power resource occupation information corresponding to 3 contract process container units associated with the contract identifier (1) is 0.8, at this time, the total adjustment number can be determined to be 0.8/0.6x3=4, so that the number of pre-expansion copy container units is 4-3=1, at this time, the container cluster management node can re-create one expansion contract process copy container unit corresponding to the second contract process container unit through the horizontal expansion and contraction component, at this time, the contract process container units associated with the contract identifier (1) become 4.
Specifically, the second horizontal expansion and contraction parameter may include a minimum occupation threshold of computing power resources and a minimum number of container units; one possible implementation process of performing the horizontal expansion and contraction processing on the second contract process container unit according to the average computing power resource occupation information and the second horizontal expansion and contraction parameter may be: if the average computing power resource occupation information is smaller than the computing power resource minimum occupation threshold, determining the number of the pre-reduced duplicate container units according to M, the computing power resource minimum occupation threshold, the minimum number of the container units and the average computing power occupation information; the difference between M and the number of pre-reduced replica container units is greater than or equal to the minimum number of container units; selecting contract process copy container units corresponding to the number of pre-reduced contract process copy container units from M-1 contract process copy container units, and taking the contract process copy container units as contract process copy container units to be reduced; and deleting the to-be-reduced contract process copy container unit when the to-be-reduced contract process copy container unit is determined to be in an idle condition, and deleting the association relation between the to-be-reduced contract process copy container unit and the third contract identification in the transaction load balancer. One possible implementation process for determining the number of pre-reduced copy container units according to the M, the minimum occupation threshold of computing power resources, the minimum number of container units, and the average computing power occupation information may be: determining the ratio of the average computing power occupation information to the minimum computing power resource occupation threshold value as an adjustment coefficient; multiplying the adjustment coefficient by M to obtain an adjustment total number; if the total number of the adjustments is greater than or equal to the minimum number of the container units, determining the difference between M and the total number of the adjustments as the number of the pre-reduced duplicate container units; if the total number of adjustments is less than the minimum number of container units, the difference between M and the minimum number of container units is determined to be the pre-reduced duplicate container unit number. The idle condition is set to avoid affecting contract execution in the contract process copy container unit to be reduced, for example, the idle condition may be that the contract process copy container unit to be reduced has no contract process executing.
Optionally, the contract dispatcher container unit further comprises a container unit destroyer; the contract process container unit comprises N contract process container units associated with a fourth contract identification, wherein N is a positive integer. The container cluster management node can acquire the calling condition of a fourth intelligent contract corresponding to the fourth contract identifier in a target time period; and if the calling condition indicates that the fourth intelligent contract meets the task-free calling condition, emptying N contract process container units associated with the fourth contract identification through a container unit destructor. The no-task call condition may be that a task transaction related to the fourth contract identifier is not received within a target period of time, which may indicate that the fourth smart contract is not called all the time, so that a contract process container unit deployed with the fourth smart contract may be emptied, thereby releasing a computing power resource corresponding to the contract process container unit deployed with the fourth smart contract.
By adopting the method provided by the embodiment of the application, the container cluster management node can dynamically manage the quantity of the contract process copy container units corresponding to the second contract process container units deployed with the third intelligent contract through the horizontal expansion and contraction component, creates new contract process copy container units to relieve the pressure of the existing M contract process container units when the average computing power resource occupation information corresponding to the M contract process container units associated with the third contract identification is too high, and deletes part of contract process copy container units to release computing power resources when the average computing power resource occupation information is too low, thereby ensuring the dynamic balance of computing power resources and ensuring more reasonable computing power resources allocated to each intelligent contract. In addition, in order to avoid resource consumption caused by a large number of intelligent contract installations, a contract process container unit without task execution for a long time can be emptied through a container unit consumer, so that dynamic and circulated scheduling of computing resources is ensured.
Further, the above data processing method may be implemented by a system architecture of different blockchain-based contract engine scheduling schemes, and for convenience of understanding, please refer to fig. 6, fig. 6 is a schematic diagram of a blockchain-based contract engine namespace according to an embodiment of the present application. The contract engine namespaces are a single namespaces in the Kubernetes, and function to realize the data processing methods proposed by the application. The namespaces in Kubernetes are a hierarchy of virtualized clusters that isolate and name the Kubernetes resources.
As shown in fig. 6, the contract engine namespace may include a contract process schedule pod, a contract audit pod, a transaction load balancer, and a contract process pod. Wherein the contract process dispatch pod (i.e., the contract dispatcher container unit referred to in the various embodiments above) is used to be responsible for dispatching all tasks of the contract transaction; the transaction load balancer (i.e., the transaction load balancer mentioned in the above embodiments) is responsible for distributing transactions of a specified contract to the appropriate contract process pod; the contract process pod (i.e., the contract process container unit mentioned in the above embodiments) is a pod that actually performs a contract task, and may continuously run a contract process for calling the smart contract method.
As shown in fig. 6, the contract process scheduling pod may include a network module, an authentication module, HPA dynamic management, contract file management, a contract process pod creator, and a contract process pod destructor. Wherein the network module is responsible for receiving transactions from the blockchain (i.e., business transactions or contract deployment transactions sent by the blockchain nodes described above); the authentication module is responsible for verifying the rights of the transaction (i.e. performing the rights verification process as mentioned in the corresponding embodiment of fig. 4 above); the HPA dynamic management is used for dynamically managing the number of copies of the contract process pod; contract file management is responsible for managing all contract files (contract codes); the contract process pod creator is responsible for creating a contract process pod; the contract process pod destructor (i.e. the container unit destructor described in the embodiment corresponding to fig. 5 above) is responsible for destroying the contract process pod.
As shown in fig. 6, a network module, a contract main code, and a contract SDK (Software Development Kit ) may be included in the contract process pod. The network module is used for receiving a transaction request from the contract process scheduler pod; the contract main code refers to contract main code written by contract developers, and the main code usually calls a contract SDK; the contract SDK is an SDK service provided by the smart contract, such as storing data, acquiring data, and the like.
It will be appreciated that the contract engine namespaces shown in FIG. 6 can be deployed at the container cluster management node, and that the functionality provided by the contract process scheduling pod, the contract auditing pod, the transaction load balancer, and the contract process pod, all of which are included, can be implemented by the container cluster management node.
Further, by the data processing method and the contract engine namespace provided by the above embodiments, the intelligent contract can be deployed to the contract process pod in the contract engine namespace and the HPA is initialized. For ease of understanding, please refer to fig. 7, fig. 7 is a flowchart illustrating an intelligent contract deployment according to an embodiment of the present application. As shown in fig. 7, the entire smart contract deployment process may include the following steps S401-S422:
in step S401, the blockchain node receives a contract deployment transaction sent by the terminal device.
Specifically, after the contract manager packs the written intelligent contract locally, parameters of an intelligent contract initialization method can be added into the intelligent contract through the terminal equipment, then the intelligent contract and the parameters are packed into contract deployment transaction, signature is carried out on the contract deployment transaction to obtain signature data, and then the contract deployment transaction and the signature data are sent to the blockchain node together.
Step S402, block link point auditing contract deployment transaction, if auditing is successful, executing step S403; if the audit is failed, step S422 is performed.
Specifically, when the block chain link point auditing contract deploys transaction, signature data can be untagged, and if the untagging is successful, the auditing is determined to be successful; if the signing releasing fails, determining that the auditing fails.
In step S403, the block link sends the contract deployment transaction to the contract process scheduler pod.
Specifically, the contract process scheduler pod has its own IP and port, so the blockchain node can send the contract deployment transaction directly into the contract process scheduler pod in the k8s cluster.
In step S404, the network module of the contract process scheduler pod receives the contract deployment transaction.
In particular, the communication of the contract process scheduler pod is effected by the network module it contains, so that the contract process scheduler pod can receive the contract deployment transaction through the network module.
Step S405, the contract process scheduler pod authentication module performs authority verification, and if the authority verification is successful, step S406 is executed; if the rights verification fails, step S416 is performed.
Specifically, the contract process fetcher pod may perform authority verification on the contract deployment transaction through the authentication module, where the authority verification process may refer to the description of the deployment authority verification process in step S201 in the embodiment corresponding to fig. 4, and the description is not repeated here.
Step S406, contract audit pod carries out contract audit, if audit is successful, step S407 is executed; if the audit fails, step S417 is performed.
Specifically, the process of contract audit can refer to the related description of the code security verification process in step S201 in the embodiment corresponding to fig. 4, which is not repeated here.
In step S407, the contract process scheduler pod saves the contract file.
Specifically, the contract file may be generated based on information associated with the smart contract included in the contract deployment transaction, such as a smart contract code, a smart contract identification. The contract process scheduler pod saves the contract file for recording and review.
In step S408, the contract process scheduler pod adds HPA dynamic management for the pod to be created.
Specifically, the contract process scheduler pod adds HPA dynamic management to the to-be-created pod, and in fact, creates a horizontal scalable object for the to-be-created pod, and the implementation process can refer to the description of the creation process of the horizontal scalable object in step S204 in the embodiment corresponding to fig. 4, which is not repeated here.
In step S409, the contract process scheduler pod creates a new contract process pod.
In step S410, the contract process scheduler pod sends a contract deployment transaction to the transaction load balancer.
In step S411, the transaction load balancer distributes the contract deployment transaction to the contract process pod.
In step S412, the contract process pod network module receives a contract deployment transaction.
Step S413, the contract process pod calls the initialization method of the contract main code, and if the initialization is successful, step S414 is executed; if the initialization fails, step S415 is performed.
Specifically, the implementation process of step S409 to step S413 may refer to the specific description of step S202 to step 204 in the embodiment corresponding to fig. 4, which is not described herein.
Step S414, the contract process pod encapsulates the result of successful execution, and step S418 is executed.
Step S415, the contract process pod encapsulates the result of the execution error, and step S418 is executed.
In step S416, the contract process scheduler pod returns an error of failure of the rights verification to the block link point, and step S418 is performed.
Step S417, the contract audit pod returns an error of contract audit failure to the block link point, and step S418 is performed.
In step S418, the block link point receives an execution result corresponding to the contract deployment transaction.
Specifically, the execution result may be one of a result of successful execution of the package, a result of failed execution of the package, an error of failed authority verification, or an error of failed contract audit.
Step S419, all the block chain nodes carry out consensus on the execution result, and if the consensus is successful, step S421 is executed; if the consensus fails, step S420 is performed.
Step S420, the block chain node returns a failure result of the common check to the terminal equipment.
In step S421, the blockchain node returns the execution result of the contract deployment transaction to the terminal device.
Specifically, the blockchain node also writes the contract deployment transaction and the execution result into the blockchain ledger.
In step S422, the blockchain node returns an error to the terminal device that the audit transaction does not pass.
Further, by the data processing method and the contract engine namespace set forth in the above embodiments, it is possible to implement calling of the smart contract already deployed in the contract process pod to execute the business transaction. For ease of understanding, fig. 8 is a schematic flow chart of intelligent contract invocation provided in an embodiment of the present application. As shown in fig. 8, the entire flow of smart contract calls may include the following steps S501-S517:
in step S501, the blockchain node receives a service transaction sent by a terminal device.
Specifically, the terminal device may respond to the service request of the service object, package the method and the parameter request for calling the intelligent contract into the service transaction, sign the service transaction to obtain signature data of the service transaction, and then send the service transaction and the signature data together to the blockchain node.
Step S502, the block link points audit the business transaction, if the audit is successful, the step S403 is executed; if the audit fails, step S517 is performed.
Specifically, when the block chain link points audit the business transaction, signature data of the business transaction can be subjected to signature releasing, and if the signature releasing is successful, the audit is determined to be successful; if the signing releasing fails, determining that the auditing fails.
In step S503, the block link sends the business transaction to the contract process scheduler pod.
Specifically, the contract process scheduler pod has its own IP and port, so the blockchain node can send the business transaction directly into the contract process scheduler pod in the k8s cluster.
In step S504, the network module of the contract process scheduler pod receives the business transaction.
In particular, the communication of the contract process scheduler pod is effected by the network module it contains, so that the contract process scheduler pod can receive business transactions via the network module.
Step S505, the contract process scheduler pod authentication module performs authority verification, and if the authority verification is successful, step S506 is executed; if the rights verification fails, step S512 is performed.
Specifically, the contract process fetcher pod may perform authority verification on the service transaction through the authentication module, where the authority verification process may refer to the description of the deployment authority verification process in step S201 in the embodiment corresponding to fig. 4, which is not repeated herein.
In step S506, the contract process scheduler pod sends the business transaction to the transaction load balancer.
In step S507, the transaction load balancer distributes the business transaction to the contract process pod.
In step S508, the contract process pod network module receives the business transaction.
Step S509, the contract process pod calls the corresponding method of the contract main code, if the transaction execution is successful, the step S510 is executed; if the transaction execution fails, step S511 is performed.
Specifically, the implementation process of step S506 to step S509 may refer to the specific description of step S101 to step S103 in the embodiment corresponding to fig. 3, which is not described herein.
Step S510, the contract process pod encapsulates the result of the execution success, and step S513 is executed.
Step S511, the contract process pod encapsulates the result of the execution error, and step S513 is executed.
Specifically, the implementation process of step S506 to step S511 may refer to the specific description of step S101 to step 103 in the embodiment corresponding to fig. 3, which is not described herein.
In step S512, the contract process scheduler pod returns an error of failure of the rights verification to the block link point, and step S513 is executed.
In step S513, the block link point receives the execution result corresponding to the service transaction.
Specifically, the execution result may be one of a result of successful execution of the package, a result of failed execution of the package, and an error of failed permission verification.
Step S514, all the block chain nodes carry out consensus on the execution result of the business transaction, and if the consensus is successful, step S516 is executed; if the consensus fails, step S515 is performed.
In step S515, the blockchain node returns a failure result of the consensus verification to the terminal device.
In step S516, the blockchain node returns the execution result of the service transaction to the terminal device.
Specifically, the blockchain node also writes the business transaction and the execution result into the blockchain ledger.
Step S517, the blockchain node returns an error to the terminal device that the audit transaction does not pass.
Further, by the data processing method and the contract engine namespace provided by the above embodiments, dynamic expansion and contraction of the contract process pod can be realized, that is, the number of copies pod corresponding to the contract process pod is continuously expanded or reduced along with the change of the computing power resource. For ease of understanding, fig. 9 is a schematic flow chart of dynamic expansion of a contract process container unit according to an embodiment of the present application. As shown in fig. 9, the entire dynamic expansion flow may include the following steps S601-S610:
Step S601, a contract process pod template is preconfigured.
Specifically, the contract process pod template may be an initial contract process container unit creation template described in the embodiment corresponding to fig. 4, and the configured contract process pod template may be stored in the contract process dispatcher pod.
Step S602, acquiring the contract process pod template when creating a new contract process pod.
In step S603, the contract process fetcher pod modifies the contract-related information in the template to the related information of the new contract.
Specifically, the implementation process of step S602 to step S603 may refer to the specific description of step S202, which is not described herein.
In step S604, the contract process scheduler pod creates an HPA object for the new contract.
Specifically, the creation process of the HPA object, that is, the horizontal expansion and contraction object described in the embodiment corresponding to fig. 4, may refer to the description of the creation of the horizontal expansion and contraction object in step S204 in the embodiment corresponding to fig. 4, and will not be described in detail here.
In step S605, the contract process scheduler pod specifies a horizontal expansion and contraction parameter in the HPA object.
Specifically, the horizontal scaling parameters may include a maximum occupancy threshold for computing power resources, a minimum occupancy threshold for computing power resources, a maximum number of container units, and a minimum number of container units. For example, the horizontal expansion and contraction parameter may be specified to be 80% of cpu maximum occupation threshold, 20% of cpu minimum occupation threshold, and 4 of container units maximum, where one contract process pod may create at most 3 contract process pod copies, and 1 of container units minimum, where one contract process pod may not have a corresponding contract process pod copy.
Specifically, referring to the following table 2, table 2 is an example YAML (a file format) file of an HPA object for implementing a pod dynamic extension according to an embodiment of the present application:
TABLE 2
It will be appreciated that table 2 above specifies the name of the target depoyment and the minimum and maximum Pod numbers. It also defines two CPU resource measurement indexes, one for capacity reduction and one for capacity expansion, when the CPU occupancy rate is lower than 50%, the HPA automatically reduces the Pod number, and when the CPU occupancy rate is higher than 70%, the HPA automatically increases the Pod number. In addition, optional parameters such as 'stability windows seconds' for preventing short CPU fluctuations from affecting the number of Pod, 'cooldown seconds' for setting cooling time between capacity reduction and capacity expansion, 'value' may be used instead of 'operationUtilization' for specifying absolute value of CPU, 'selector' for specifying tag selector of Pod of interest.
In step S606, the contract process pod is started.
In step S607, the resource detecting component in the contract process pod is started.
In step S608, the resource detection component sends the computing power resource occupation information to the API server in k8S in real time.
In step S609, the HPA automatically adjusts the number of pod copies according to the average computing power resource occupation information.
Specifically, the API server sends the received computing power resource occupation information to the HPA, the HPA determines average computing power resource occupation information corresponding to an intelligent contract according to computing power resource occupation information of objects of all contract processes pod associated with the intelligent contract, and then adjusts the number of copies of the contract process pod corresponding to the intelligent contract according to the average computing power resource occupation information. The specific implementation process of adjusting the number of the point of contact pod copies may refer to the specific description of step S302 in the embodiment corresponding to fig. 5, which is not described herein.
In step S610, the contract process pod destructor empties the contract process pod and pod copy corresponding to the smart contract when the smart contract satisfies the task-free call condition.
In particular, the implementation of step S610 may refer to the specific description of the container unit emptying contract process of the container unit destructor in the embodiment corresponding to fig. 5, which is not repeated herein.
All the blockchain contract processes are managed through the system architecture of the blockchain contract engine namespaces, and the authority problem and the resource management problem between the contract processes can be automatically solved. The application also uses HPA to dynamically manage the number of pod copies of each intelligent contract, automatically adjusts the number when the CPU occupation is too high or too low, ensures the dynamic balance of resources, and ensures more reasonable resource utilization of each intelligent contract. In addition, in order to avoid resource consumption caused by installation of a large number of intelligent contracts, the application also adds a contract process pod destructor, and when the contract process pod has no task for a long time, the pod is destroyed, so that dynamic and circulated scheduling of resources is ensured. In order to avoid the influence of leaky contracts on the environmental stability, the application also adds a contract audit pod, and each intelligent contract needs to be audited first when being installed, thereby avoiding the influence of unsafe contracts on the system environment.
Referring to fig. 10, fig. 10 is a schematic structural diagram of a data processing apparatus based on a blockchain according to an embodiment of the present application. The data processing apparatus may be a computer program (including program code) running on a computer device, for example the data processing apparatus is an application software; the data processing apparatus 1 may be used to perform corresponding steps in a blockchain-based data processing method provided by an embodiment of the present application. As shown in fig. 10, the data processing apparatus 1 may include: scheduling module 101, load balancing module 102 and execution module 103.
The scheduling module 101 is configured to receive, through the contract scheduler container unit, a service transaction sent by the blockchain node, and forward the service transaction to the transaction load balancer; the business transaction comprises a first contract identification corresponding to the first intelligent contract;
a load balancing module 102, configured to obtain, in a transaction load balancer, one or more contract process container units associated with the first contract identifier from a contract process container unit set, and select, from the one or more contract process container units, a contract process container unit that meets an idle scheduling condition as a target contract process container unit; the one or more contract process container units are provided with a first intelligent contract;
And the execution module 103 is configured to send the business transaction to the target contract process container unit through the transaction load balancer, call the first intelligent contract to execute the business transaction in the target contract process container unit, obtain a transaction execution result, and send the transaction execution result to the blockchain node.
The specific implementation manner of the scheduling module 101, the load balancing module 102, and the executing module 103 may refer to the specific description of step S101 to step S103 in the embodiment corresponding to fig. 3, which is not repeated here.
Wherein, the load balancing module 102 comprises: a first acquisition unit 1021, a second acquisition unit 1022, and a determination unit 1023.
A first obtaining unit 1021, configured to obtain, in the transaction load balancer, one or more contract process container units associated with the first contract identification from the contract process container unit set;
a second obtaining unit 1022, configured to obtain computing power resource occupation information corresponding to one or more contract process container units associated with the first contract identifier, and determine a contract process container unit with the smallest computing power resource occupation information as a contract process container unit that meets an idle scheduling condition;
A determining unit 1023, configured to take the contract process container unit meeting the idle schedule condition as a target contract process container unit.
The specific implementation manner of the first acquiring unit 1021, the second acquiring unit 1022, and the determining unit 1023 may refer to the specific description of step S102 in the embodiment corresponding to fig. 3, which is not described herein.
Wherein, the above-mentioned data processing apparatus 1, further include: a receiving module 104, a creating module 105, a sending module 106, a forwarding module 107 and an initializing module 108.
A receiving module 104 for receiving, by the contract dispatcher container unit, a contract deployment transaction sent by the blockchain node; the contract deployment transaction comprises a second contract identifier corresponding to the second intelligent contract and an intelligent contract code;
a creation module 105 for creating a first contract process container unit from the contract deployment transaction; the first contract process container unit contains intelligent contract codes;
a sending module 106, configured to send the association between the contract deployment transaction and the second contract identifier and the first contract process container unit to the transaction load balancer;
a forwarding module 107, configured to forward, in the transaction load balancer, the contract deployment transaction to the first contract process container unit according to the association relationship between the second contract identification and the first contract process container unit;
An initialization module 108, configured to invoke an intelligent contract code to perform a contract initialization process according to a contract deployment transaction in a first contract process container unit, obtain a contract initialization result, and send the contract initialization result to a blockchain node; the contract initialization results are used to characterize deployment of the second intelligent contract in the first contract process container unit.
The specific implementation manner of the receiving module 104, the creating module 105, the sending module 106, the forwarding module 107, and the initializing module 108 may refer to the specific description of the step S201 to the step S204 in the embodiment corresponding to the above-mentioned fig. 4, and the detailed description is omitted here.
Wherein the contract dispatcher container unit comprises an initial contract process container unit creation template and a container unit creator;
the creation module 105 includes: a third acquisition unit 1051, and a creation unit 1052.
A third obtaining unit 1051, configured to obtain, in the contract dispatcher container unit, an initial contract process container unit creation template, update the initial contract process container unit creation template according to the intelligent contract code, and obtain a deployment contract process container unit creation template;
a creation unit 1052 for creating a first contract process container unit by running the deployment contract process container unit template by the container unit creator.
The specific implementation manner of the third obtaining unit 1051 and the creating unit 1052 may refer to the specific description of step S202 in the embodiment corresponding to fig. 4, which is not repeated here.
Wherein the contract deployment transaction comprises transaction initiation object information;
the data processing apparatus 1 further includes: the rights verification module 109.
The authority verification module 109 is configured to perform deployment authority verification processing according to the transaction initiation object information in the contract dispatcher container unit, to obtain a deployment authority verification result;
the rights verification module 109 is further configured to, if the deployment rights verification result is a deployment rights verification passing result, invoke the creation module to execute a step of creating a first contract process container unit according to the contract deployment transaction;
the permission verification module 109 is further configured to send permission verification failure prompt information to the blockchain node if the deployment permission verification result is a deployment permission verification failure result.
The specific implementation manner of the permission verification module 109 may refer to the optional description of step S201 in the embodiment corresponding to fig. 4, which is not described herein.
Wherein the container cluster management node further comprises a contract auditing container unit;
The data processing apparatus 1 further includes: contract auditing module 110.
A contract auditing module 110 for acquiring the intelligent contract code from the contract deployment transaction through the contract dispatcher container unit and transmitting the intelligent contract code to the contract auditing container unit;
the contract auditing module 110 is further configured to perform code security verification processing on the intelligent contract code in the contract auditing container unit, obtain a security verification result, and send the security verification result to the contract dispatcher container unit;
the contract auditing module 110 is further configured to, if the security verification result is a security verification passing result, invoke the creating module to execute a step of creating a first contract process container unit according to the contract deployment transaction in the contract dispatcher container unit;
the contract audit module 110 is further configured to send, if the security verification result is a security verification failure result, a security verification failure prompt message to the blockchain node through the contract dispatcher container unit.
The specific implementation of the contract auditing module 110 may refer to the optional description of step S201 in the embodiment corresponding to fig. 4, and will not be described herein.
Wherein the contract deployment transaction further includes a first horizontal scaling parameter; the container cluster management node also comprises a horizontal expansion and contraction component;
The data processing apparatus 1 further includes: the scalable object creation module 111.
A scalable object creation module 111, configured to create, in the contract dispatcher container unit, a horizontal scalable object corresponding to the second contract identifier according to the first horizontal scalable parameter; the horizontal expansion and contraction object corresponding to the second contract identification is used for indicating the horizontal expansion and contraction component to adjust the quantity of contract process copy container units corresponding to the first contract process container units according to the average computing power resource occupation information corresponding to the second contract identification and the first horizontal expansion and contraction parameter; the contract process copy container unit is created by the horizontal expansion and contraction component according to the first contract process container unit; the first contract process container unit and the contract process copy container unit corresponding to the first contract process container unit form a contract process container unit set, and the second contract identifies one or more associated contract process container units.
The specific implementation manner of the scalable object creation module 111 may refer to the optional description of step 204 in the embodiment corresponding to fig. 4, and will not be described herein.
Wherein the container cluster management node further comprises a horizontal expansion and contraction component; the contract process container unit set comprises M contract process container units associated with a third contract identification; the M contract process container units comprise second contract process container units and M-1 contract process copy container units, wherein M is a positive integer; m-1 contract process copy container units are all created by the horizontal expansion and contraction component according to a second contract process container unit; the M contract process container units are all deployed with a third intelligent contract corresponding to a third contract identifier;
The data processing apparatus 1 further includes: an information acquisition module 112, a parameter acquisition module 113, and a horizontal expansion and contraction module 114.
The information obtaining module 112 is configured to obtain, by using the horizontal expansion and contraction component, average computing power resource occupation information corresponding to the third contract identifier; the average computing power resource occupation information is obtained by carrying out average processing according to computing power resource occupation information respectively corresponding to M contract process container units;
the parameter obtaining module 113 is configured to obtain a second horizontal expansion and contraction parameter corresponding to the third contract identifier;
the horizontal expansion and contraction module 114 is configured to perform horizontal expansion and contraction processing on the M contract process container units according to the average computing power resource occupation information and the second horizontal expansion and contraction parameter.
The specific implementation manner of the information obtaining module 112, the parameter obtaining module 113, and the horizontal expansion and contraction module 114 may be referred to the specific description of step S301 to step S302 in the embodiment corresponding to fig. 5, which is not repeated here.
Wherein the second horizontal expansion and contraction parameter comprises a maximum occupation threshold value of computing power resources and a maximum number of container units;
a horizontal expansion and contraction module 114 comprising: an expansion number determination unit 1141 and an expansion unit 1142.
The expansion number determining unit 1141 is configured to determine, if the average computing power resource occupation information exceeds the computing power resource maximum occupation threshold, the number of pre-expansion copy container units according to M, the computing power resource maximum occupation threshold, the maximum number of container units, and the average computing power occupation information; the sum of M and the number of pre-expanded replica container units is less than or equal to the maximum number of container units;
the expansion unit 1142 is configured to create expansion contract process copy container units corresponding to the number of pre-expansion contract process container units according to the second contract process container unit, add the expansion contract process copy container units to the contract process container unit set, and send the association relationship between the expansion contract process copy container units and the third contract identifier to the traffic load balancer.
The specific implementation manner of the expansion number determining unit 1141 and the expansion unit 1142 may refer to the specific description of step S302 in the embodiment corresponding to fig. 5, which is not described herein.
Wherein the expansion number determining unit 1141 includes: coefficient determination subunit 11411 and calculation subunit 11412.
A coefficient determining subunit 11411, configured to determine, as an adjustment coefficient, a ratio of the average computing power occupation information to the maximum computing power resource occupation threshold;
A calculating subunit 11412, configured to multiply the adjustment coefficient by M to perform rounding processing, to obtain an adjustment total number;
the calculating subunit 11412 is further configured to determine, if the total number of adjustments is less than or equal to the maximum number of container units, a difference between the total number of adjustments and M as the number of pre-expanded copy container units;
the calculating subunit 11412 is further configured to determine, if the total number of adjustments is greater than the maximum number of container units, a difference between the maximum number of container units and M as the number of pre-expanded copy container units.
The specific implementation of the coefficient determination subunit 11411 and the calculation subunit 11412 may refer to the specific description of step S302 in the embodiment corresponding to fig. 5, which is not described herein.
Wherein the second horizontal expansion and contraction parameter comprises a minimum occupation threshold value of computing power resources and a minimum number of container units;
a horizontal expansion and contraction module 114 comprising: a reduction number determination unit 1143 and a reduction unit 1144.
The reduced number determining unit 1143 is configured to determine, if the average computing power resource occupancy information is smaller than the computing power resource minimum occupancy threshold, the number of pre-reduced duplicate container units according to M, the computing power resource minimum occupancy threshold, the minimum number of container units, and the average computing power occupancy information; the difference between M and the number of pre-reduced replica container units is greater than or equal to the minimum number of container units;
The reducing unit 1144 is configured to select, from M-1 contract process copy container units, a contract process copy container unit corresponding to the number of pre-reduced contract process copy container units, as a contract process copy container unit to be reduced;
the reducing unit 1144 is further configured to delete the to-be-reduced contract process replica container unit when it is determined that the to-be-reduced contract process replica container unit is in an idle condition, and in the transaction load balancer, delete an association relationship between the to-be-reduced contract process replica container unit and the third contract identifier.
The specific implementation of the reduction number determining unit 1143 and the reduction unit 1144 may refer to the specific description of step S302 in the embodiment corresponding to fig. 5, which is not repeated here.
Wherein the contract dispatcher container unit further comprises a container unit destroyer; the contract process container unit comprises N contract process container units associated with a fourth contract identifier, wherein N is a positive integer;
the data processing apparatus 1 further includes: the acquisition module 115 and the emptying module 116 are invoked.
A call obtaining module 115, configured to obtain a call condition of a fourth intelligent contract corresponding to the fourth contract identifier in a target time period;
And a flushing module 116, configured to flush, by the container unit destructor, the N contract process container units associated with the fourth contract identifier if the call condition indicates that the fourth smart contract satisfies the no-task call condition.
The specific implementation manner of the call acquisition module 115 and the emptying module 116 may refer to the optional description of step S302 in the embodiment corresponding to fig. 5, which is not repeated here.
Referring to fig. 11, fig. 11 is a schematic structural diagram of a computer device according to an embodiment of the application. As shown in fig. 11, the data processing apparatus 1 in the embodiment corresponding to fig. 10 described above may be applied to a computer device 1000, and the computer device 1000 may include: processor 1001, network interface 1004, and memory 1005, and in addition, the above-described computer device 1000 may further include: a user interface 1003, and at least one communication bus 1002. Wherein the communication bus 1002 is used to enable connected communication between these components. The user interface 1003 may include a Display (Display), a Keyboard (Keyboard), and the optional user interface 1003 may further include a standard wired interface, a wireless interface, among others. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one disk memory. The memory 1005 may also optionally be at least one storage device located remotely from the processor 1001. As shown in fig. 11, an operating system, a network communication module, a user interface module, and a device control application may be included in the memory 1005, which is one type of computer-readable storage medium.
In the computer device 1000 shown in fig. 11, the network interface 1004 may provide a network communication network element; while user interface 1003 is primarily used as an interface for providing input to a user; and the processor 1001 may be used to invoke a device control application stored in the memory 1005 to implement:
receiving the business transaction sent by the blockchain node through a contract scheduler container unit, and forwarding the business transaction to a transaction load balancer; the business transaction comprises a first contract identification corresponding to the first intelligent contract;
in the transaction load balancer, one or more contract process container units associated with a first contract identification are acquired from a contract process container unit set, and a contract process container unit meeting idle scheduling conditions is selected from the one or more contract process container units to serve as a target contract process container unit; the one or more contract process container units are provided with a first intelligent contract;
and sending the business transaction to a target contract process container unit through a transaction load balancer, calling a first intelligent contract to execute the business transaction in the target contract process container unit to obtain a transaction execution result, and sending the transaction execution result to the blockchain node.
It should be understood that the computer device 1000 described in the embodiments of the present application may perform the description of the data processing method in any of the embodiments corresponding to the foregoing fig. 3, and will not be repeated herein. In addition, the description of the beneficial effects of the same method is omitted.
Furthermore, it should be noted here that: the embodiment of the present application further provides a computer readable storage medium, in which the aforementioned computer program executed by the data processing apparatus 1 is stored, and the computer program includes program instructions, when executed by the processor, can execute the description of the data processing method in any of the corresponding embodiments of fig. 3, and therefore, a detailed description will not be given here. In addition, the description of the beneficial effects of the same method is omitted. For technical details not disclosed in the embodiments of the computer-readable storage medium according to the present application, please refer to the description of the method embodiments of the present application.
The computer readable storage medium may be the data processing apparatus provided in any one of the foregoing embodiments or an internal storage unit of the computer device, for example, 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 Media Card (SMC), a Secure Digital (SD) card, a flash card (flash card) or the like, which are provided on the computer device. Further, the computer-readable storage medium may also include both internal storage units and external storage devices of the computer device. The computer-readable storage medium is used to store 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.
Furthermore, it should be noted here that: embodiments of the present application also provide a 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 executes the computer instructions to cause the computer device to perform the method provided by the corresponding embodiment of any of the preceding figures 3, 4.
The terms first, second and the like in the description and in the claims and drawings of embodiments of the application are used for distinguishing between different objects and not for describing a particular sequential order. Furthermore, the term "include" and any variations thereof is intended to cover a non-exclusive inclusion. For example, a process, method, apparatus, article, or device that comprises a list of steps or elements is not limited to the list of steps or modules but may, in the alternative, include other steps or modules not listed or inherent to such process, method, apparatus, article, or device.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps described in connection with the embodiments disclosed herein may be embodied as electronic hardware, as a computer software, or in a combination of the two, and that the elements and steps of the examples have been generally described in terms of network elements in the foregoing description to clearly illustrate the interchangeability of hardware and software. Whether these network elements are implemented in hardware or software depends on the specific application and design constraints of the solution. The skilled person may use different methods for implementing the described network elements for each specific application, but such implementation should not be considered to be beyond the scope of the present application.
The foregoing disclosure is illustrative of the present application and is not to be construed as limiting the scope of the application, which is defined by the appended claims.

Claims (14)

1. A data processing method based on a block chain is characterized in that a block chain network comprises block chain nodes and container cluster management nodes corresponding to the block chain link points; the container cluster management node comprises a contract dispatcher container unit, a transaction load balancer, a horizontal expansion and contraction component and a contract process container unit set; the contract process container unit set comprises M contract process container units associated with a third contract identification; the M contract process container units comprise second contract process container units and M-1 contract process copy container units, wherein M is a positive integer; the M-1 contract process copy container units are all created by the horizontal expansion and contraction component according to the second contract process container unit; the M contract process container units are all deployed with a third intelligent contract corresponding to the third contract identifier; the method is performed by a container cluster management node; the method comprises the following steps:
Receiving a business transaction sent by the blockchain node through the contract scheduler container unit, and forwarding the business transaction to the transaction load balancer; the business transaction comprises a first contract identification corresponding to a first intelligent contract;
in the transaction load balancer, acquiring one or more contract process container units associated with the first contract identification from the contract process container unit set, and selecting a contract process container unit meeting idle scheduling conditions from the one or more contract process container units as a target contract process container unit; the one or more contract process container units each have the first smart contract deployed therein;
the business transaction is sent to the target contract process container unit through the transaction load balancer, the first intelligent contract is called to execute the business transaction in the target contract process container unit, a transaction execution result is obtained, and the transaction execution result is sent to the blockchain node;
acquiring average computing power resource occupation information corresponding to the third contract identification through the horizontal expansion and contraction component; the average computing power resource occupation information is obtained by carrying out average processing according to computing power resource occupation information respectively corresponding to the M contract process container units;
Acquiring a second horizontal expansion and contraction parameter corresponding to the third contract identifier;
and carrying out horizontal expansion and contraction processing on the M contract process container units according to the average computing power resource occupation information and the second horizontal expansion and contraction parameters.
2. The method of claim 1, wherein in the transaction load balancer, obtaining one or more contract process container units associated with the first contract identification from the contract process container unit set, selecting a contract process container unit meeting idle schedule conditions from the one or more contract process container units as a target contract process container unit, comprises:
in the transaction load balancer, obtaining one or more contract process container units associated with the first contract identification from the contract process container unit set;
acquiring computing power resource occupation information corresponding to one or more contract process container units associated with the first contract identification, and determining the contract process container unit with the smallest computing power resource occupation information as the contract process container unit conforming to idle scheduling conditions;
and taking the contract process container unit meeting the idle scheduling condition as a target contract process container unit.
3. The method as recited in claim 1, further comprising:
receiving, by the contract scheduler container unit, a contract deployment transaction sent by the blockchain node; the contract deployment transaction comprises a second contract identifier corresponding to a second intelligent contract and an intelligent contract code;
creating a first contract process container unit from the contract deployment transaction; the first contract process container unit contains the intelligent contract code;
transmitting the association of the contract deployment transaction and the second contract identification with the first contract process container unit to the transaction load balancer;
forwarding, in the transaction load balancer, the contract deployment transaction to the first contract process container unit according to an association of the second contract identification with the first contract process container unit;
in the first contract process container unit, calling the intelligent contract code to perform contract initialization processing according to the contract deployment transaction to obtain a contract initialization result, and sending the contract initialization result to the blockchain node; the contract initialization result is used for representing deployment conditions of the second intelligent contract in the first contract process container unit.
4. The method of claim 3, wherein the contract dispatcher container unit includes an initial contract process container unit creation template and a container unit creator;
the creating a first contract process container unit from the contract deployment transaction includes:
in the contract dispatcher container unit, acquiring the initial contract process container unit creation template, and updating the initial contract process container unit creation template according to the intelligent contract code to obtain a deployment contract process container unit creation template;
and operating the deployment contract process container unit template through the container unit creator to create the first contract process container unit.
5. The method of claim 3, wherein the contract deployment transaction includes transaction initiation object information; the method further comprises the steps of:
in the contract dispatcher container unit, performing deployment permission verification processing according to the transaction initiating object information to obtain a deployment permission verification result;
if the deployment right verification result is a deployment right verification passing result, executing the step of creating a first contract process container unit according to the contract deployment transaction;
And if the deployment permission verification result is a deployment permission verification failure result, sending permission verification failure prompt information to the blockchain node.
6. The method of claim 3, wherein the container cluster management node further comprises a contract audit container unit; the method further comprises the steps of:
acquiring the intelligent contract code from the contract deployment transaction by the contract dispatcher container unit, and sending the intelligent contract code to the contract audit container unit;
in the contract auditing container unit, performing code security verification processing on the intelligent contract code to obtain a security verification result, and sending the security verification result to the contract dispatcher container unit;
if the security verification result is a security verification passing result, executing the step of creating a first contract process container unit according to the contract deployment transaction in the contract dispatcher container unit;
and if the security verification result is a security verification failure result, sending a security verification failure prompt message to a blockchain node through the contract dispatcher container unit.
7. The method of claim 3, wherein the contract deployment transaction further includes a first horizontal scaling parameter; the container cluster management node further comprises a horizontal expansion and contraction component;
The method further comprises the steps of:
creating, in the contract scheduler container unit, a horizontal scaling object corresponding to the second contract identification according to the first horizontal scaling parameter; the horizontal expansion and contraction object corresponding to the second contract identifier is used for indicating the horizontal expansion and contraction component to adjust the number of contract process copy container units corresponding to the first contract process container unit according to the average computing power resource occupation information corresponding to the second contract identifier and the first horizontal expansion and contraction parameter; the contract process copy container unit is created by the horizontal expansion and contraction component according to the first contract process container unit; the first contract process container unit and the contract process copy container unit corresponding to the first contract process container unit form one or more contract process container units in the contract process container unit set, and the second contract identifies the associated one or more contract process container units.
8. The method of claim 1, wherein the second horizontal scaling parameter comprises a maximum occupancy threshold for computing power resources and a maximum number of container units;
the performing the horizontal expansion and contraction processing on the M contract process container units according to the average computing power resource occupation information and the second horizontal expansion and contraction parameter includes:
If the average computing power resource occupation information exceeds the computing power resource maximum occupation threshold, determining the number of pre-expanded copy container units according to the M, the computing power resource maximum occupation threshold, the maximum number of container units and the average computing power resource occupation information; the sum of the M and the number of pre-expanded replica container units is less than or equal to the maximum number of container units;
creating extension contract process copy container units corresponding to the number of the pre-extension copy container units according to the second contract process container units, adding the extension contract process copy container units to the contract process container unit set, and sending the association relation between the extension contract process copy container units and the third contract identification to the transaction load balancer.
9. The method of claim 8, wherein the determining a pre-expanded number of replica container units from the M, the maximum occupancy threshold for computing power resources, the maximum number of container units, and the average computing power resource occupancy information comprises:
determining the ratio of the average computing power resource occupation information to the maximum computing power resource occupation threshold value as an adjustment coefficient;
Multiplying the adjustment coefficient by M to obtain an adjustment total number;
if the total adjustment amount is smaller than or equal to the maximum container unit amount, determining a difference value between the total adjustment amount and the M as a pre-expansion copy container unit amount;
and if the total adjustment quantity is larger than the maximum quantity of container units, determining the difference value between the maximum quantity of container units and M as the quantity of pre-expansion copy container units.
10. The method of claim 1, wherein the second horizontal scaling parameter comprises a minimum occupancy threshold for computing resources and a minimum number of container units;
the performing the horizontal expansion and contraction processing on the M contract process container units according to the average computing power resource occupation information and the second horizontal expansion and contraction parameter includes:
if the average computing power resource occupation information is smaller than the computing power resource minimum occupation threshold, determining the number of pre-reduced duplicate container units according to the M, the computing power resource minimum occupation threshold, the minimum number of container units and the average computing power resource occupation information; the difference between the M and the number of pre-reduced duplicate container units is greater than or equal to the minimum number of container units;
Selecting contract process copy container units corresponding to the number of the pre-reduced copy container units from the M-1 contract process copy container units as contract process copy container units to be reduced;
and deleting the to-be-reduced contract process copy container unit when the to-be-reduced contract process copy container unit is determined to be in an idle condition, and deleting the association relationship between the to-be-reduced contract process copy container unit and the third contract identification in the transaction load balancer.
11. The method of claim 1, wherein the contract dispatcher container unit further comprises a container unit destroyer; the contract process container unit comprises N contract process container units associated with a fourth contract identifier, wherein N is a positive integer;
the method further comprises the steps of:
acquiring the calling condition of a fourth intelligent contract corresponding to the fourth contract identifier in a target time period;
and if the calling condition indicates that the fourth intelligent contract meets the task-free calling condition, emptying N contract process container units associated with the fourth contract identification through the container unit destructor.
12. A data processing device based on a block chain is characterized in that a block chain network comprises block chain nodes and container cluster management nodes corresponding to the block chain nodes; the container cluster management node comprises a contract dispatcher container unit, a transaction load balancer, a horizontal expansion and contraction component and a contract process container unit set; the contract process container unit set comprises M contract process container units associated with a third contract identification; the M contract process container units comprise second contract process container units and M-1 contract process copy container units, wherein M is a positive integer; the M-1 contract process copy container units are all created by the horizontal expansion and contraction component according to the second contract process container unit; the M contract process container units are all deployed with a third intelligent contract corresponding to the third contract identifier; the device is operated by a container cluster management node; the device comprises:
The scheduling module is used for receiving the business transaction sent by the blockchain node through the contract scheduler container unit and forwarding the business transaction to the transaction load balancer; the business transaction comprises a first contract identification corresponding to a first intelligent contract;
the load balancing module is used for acquiring one or more contract process container units associated with the first contract identification from the contract process container unit set in the transaction load balancer, and selecting the contract process container units meeting idle scheduling conditions from the one or more contract process container units as target contract process container units; the one or more contract process container units each have the first smart contract deployed therein;
an execution module, configured to send the business transaction to the target contract process container unit through the transaction load balancer, call the first intelligent contract to execute the business transaction in the target contract process container unit to obtain a transaction execution result, and send the transaction execution result to the blockchain node
The information acquisition module is used for acquiring average computing power resource occupation information corresponding to the third contract identification through the horizontal expansion and contraction component; the average computing power resource occupation information is obtained by carrying out average processing according to computing power resource occupation information respectively corresponding to the M contract process container units;
The parameter acquisition module is used for acquiring a second horizontal expansion and contraction parameter corresponding to the third contract identifier;
and the horizontal expansion and contraction module is used for carrying out horizontal expansion and contraction processing on the M contract process container units according to the average computing power resource occupation information and the second horizontal expansion and contraction parameters.
13. A computer device, comprising: a processor, a memory, and a network interface;
the processor is connected to the memory, the network interface for providing data communication functions, the memory for storing program code, the processor for invoking the program code to perform the method of any of claims 1-11.
14. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein a computer program adapted to be loaded by a processor and to perform the method of any of claims 1-11.
CN202310942048.3A 2023-07-29 2023-07-29 Block chain-based data processing method, device, equipment and readable storage medium Active CN116804949B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310942048.3A CN116804949B (en) 2023-07-29 2023-07-29 Block chain-based data processing method, device, equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310942048.3A CN116804949B (en) 2023-07-29 2023-07-29 Block chain-based data processing method, device, equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN116804949A CN116804949A (en) 2023-09-26
CN116804949B true CN116804949B (en) 2023-11-14

Family

ID=88080755

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310942048.3A Active CN116804949B (en) 2023-07-29 2023-07-29 Block chain-based data processing method, device, equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN116804949B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110392052A (en) * 2019-07-22 2019-10-29 中国工商银行股份有限公司 A kind of block chain intelligence contract processing system and method
CN110780988A (en) * 2018-07-31 2020-02-11 重庆小雨点小额贷款有限公司 Task triggering method and device and computer readable storage medium
CN111538521A (en) * 2020-04-24 2020-08-14 中国工商银行股份有限公司 Intelligent contract deployment and transaction method and device
CN112131006A (en) * 2020-09-27 2020-12-25 腾讯科技(深圳)有限公司 Service request distribution method, device, computer equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111815330A (en) * 2020-08-31 2020-10-23 支付宝(杭州)信息技术有限公司 Method for deploying intelligent contract, block chain node and storage medium
US20230205578A1 (en) * 2021-12-29 2023-06-29 Dell Products L.P. Error Avoidance Load Balancing Across Distributed Clustered Containerized Environments

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110780988A (en) * 2018-07-31 2020-02-11 重庆小雨点小额贷款有限公司 Task triggering method and device and computer readable storage medium
CN110392052A (en) * 2019-07-22 2019-10-29 中国工商银行股份有限公司 A kind of block chain intelligence contract processing system and method
CN111538521A (en) * 2020-04-24 2020-08-14 中国工商银行股份有限公司 Intelligent contract deployment and transaction method and device
CN112131006A (en) * 2020-09-27 2020-12-25 腾讯科技(深圳)有限公司 Service request distribution method, device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN116804949A (en) 2023-09-26

Similar Documents

Publication Publication Date Title
CN111461723B (en) Data processing system, method and device based on block chain
CN112686671B (en) Intelligent contract deployment method, device, equipment and medium based on block chain
CN111368330B (en) Ethernet intelligent contract auditing system and method based on block chain
CN111737104A (en) Block chain network service platform, test case sharing method thereof and storage medium
CN112381543A (en) Multiple signature transaction method, device and storage medium
CN113837760B (en) Data processing method, data processing device, computer equipment and storage medium
CN102197390B (en) Providing functionality to client services by implementing and binding contracts
CN113095825B (en) Asset management method and device based on block chain and electronic equipment
CN112269838B (en) Blockchain-based supervision method and device, electronic equipment and storage medium
CN114268638A (en) Block chain platform channel management method and device, computer equipment and storage medium
US11736299B2 (en) Data access control for edge devices using a cryptographic hash
CN110458541B (en) Object replacement method and device based on block chain
CN116804949B (en) Block chain-based data processing method, device, equipment and readable storage medium
CN117057913A (en) Block chain management method, device, computer, storage medium and program product
CN111782615B (en) Block chain-based large file storage method and system and computer equipment
US10771242B2 (en) Blockchain-based data processing
CN112631623A (en) Chain code deployment method, system, device, equipment and storage medium
CN115250354A (en) Resource allocation method, device, equipment and storage medium based on block chain network
CN116974764A (en) Block chain-based data processing method, device, equipment and readable storage medium
CN117032998B (en) Block chain-based data processing method and device and readable storage medium
US20120072599A1 (en) Thin client system, management server, client environment management method and program
CN116975158B (en) Request processing method, apparatus, computer device and storage medium
CN117056084B (en) Data processing method, device, equipment and medium based on hierarchical blockchain network
CN113051152B (en) Task data generation method and device and processing equipment
CN117333178A (en) Data processing method and device based on block chain and related equipment

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
GR01 Patent grant
GR01 Patent grant
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40091950

Country of ref document: HK