Data processing method based on blockchain, and device and readable storage medium
Through the segmentation and assembly of the intermediate code of the smart contract, the problem of storage capacity restrictions and artificial approval errors during the deployment and installation process of smart contracts has been solved, and more efficient deployment and installation have been achieved.
Patent Information
- Application Number
- PCT/CN2023/130446
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-07-20
- Filing Date
- 2023-11-08
- Publication Date
- 2025-01-23
AI Technical Summary
The existing technology has problems such as storage capacity limitation, low deployment applicability and manual approval errors during the deployment and installation of smart contracts.
By sharding the intermediate code of the smart contract, multiple program shards are generated and sent to the blockchain network, so that the blockchain node can assemble the complete intermediate code and realize the deployment and installation of the smart contract.
Improve the applicability and installation efficiency of smart contract deployment, avoid artificial approval errors, and relieve restrictions on the storage capacity of the middle code in the smart contract.
Smart Images

Figure CN2023130446_23012025_PF_FP_ABST
Abstract
Description
A data processing method, device and readable storage medium based on blockchain
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on July 20, 2023, with application number 202310898387.6 and application name “A Blockchain-based Data Processing Method, Device and Readable Storage Medium”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of Internet technology, and in particular to a blockchain-based data processing method, a blockchain-based data processing device, a computer device, a computer-readable storage medium, and a computer program product. Background Art
[0003] Smart contracts are automated programs based on blockchain technology that can execute transactions and agreements without an intermediary. They feature decentralization, transparency, security, and programmability. Smart contracts need to be deployed on blockchain nodes. Existing technologies include the following two deployment methods: First, blockchain nodes package the smart contract into a block, reach consensus on the block through a consensus mechanism, and successfully deploy the smart contract. However, to ensure blockchain security, consensus on blocks must be reached as quickly as possible. Therefore, blockchains impose size limits on blocks, which in turn limits the size of smart contracts. This reduces the applicability of smart contract deployment. Second, the smart contract source code is packaged into an installable package, which is then installed on each blockchain node. Blockchain node administrators manually verify the package's legitimacy. However, pre-installing smart contract packages offline not only reduces smart contract installation efficiency but also risks manual approval errors.
[0004] Summary of the Invention
[0005] The embodiments of the present application provide a blockchain-based data processing method, device, and readable storage medium, which can not only improve the applicability of smart contract deployment, but also improve the installation efficiency of smart contracts and avoid manual approval errors.
[0006] On the one hand, an embodiment of the present application provides a data processing method based on blockchain, which is executed by a business device and includes:
[0007] The intermediate code corresponding to the smart contract is fragmented to obtain A byte arrays; A is a positive integer greater than 1;
[0008] Generate A program slices according to the number of each byte array, the total number of slices A and each byte array, where each byte array corresponds to a program slice;
[0009] A program shards are sent to the blockchain network so that the blockchain nodes in the blockchain network can process the A program shards on the chain; the A program shards that have been on the chain are used to be assembled to generate a complete intermediate code.
[0010] On the one hand, an embodiment of the present application provides a data processing method based on blockchain, which is executed by a blockchain node and includes:
[0011] Obtain the program shards initiated by the business device and uploaded to the chain, and obtain the total number of shards A among the uploaded program shards; A is a positive integer greater than 1; the business device is used to shard the intermediate code corresponding to the smart contract to obtain A byte arrays; each byte array corresponds to a program shard;
[0012] Count the total number of program shards that have been uploaded to the chain. If the total number is equal to the total number of shards A, assemble the byte arrays included in each of the A program shards according to their serial numbers to obtain the complete intermediate code.
[0013] On one hand, an embodiment of the present application provides a blockchain-based data processing device, which runs on a business device and includes:
[0014] The code processing module is used to shard the intermediate code corresponding to the smart contract to obtain A byte arrays; A is a positive integer greater than 1;
[0015] A fragment generation module is used to generate A program fragments according to the number of each byte array, the total number of fragments A and each byte array, where each byte array corresponds to a program fragment;
[0016] The shard sending module is used to send A program shards to the blockchain network so that the blockchain nodes in the blockchain network can process the A program shards on the chain; the A program shards that have been on the chain are used to be assembled to generate a complete intermediate code.
[0017] In one aspect, an embodiment of the present application provides a blockchain-based data processing device, which runs on a blockchain node and includes:
[0018] The shard acquisition module is used to obtain program shards initiated by the business device and uploaded to the chain, and obtain the total number of shards A among the uploaded program shards; A is a positive integer greater than 1; the business device is used to shard the intermediate code corresponding to the smart contract to obtain A byte arrays; each byte array corresponds to a program shard;
[0019] The array assembly module is used to count the total number of program fragments that have been uploaded to the chain. If the total number is equal to the total number of fragments A, the byte arrays included in the A program fragments are assembled according to the numbers included in the A program fragments to obtain the complete intermediate code.
[0020] On one hand, the present application provides a computer device, including: a processor, a memory, and a network interface;
[0021] The above-mentioned processor is connected to the above-mentioned memory and the above-mentioned network interface, wherein the above-mentioned network interface is used to provide a data communication function, the above-mentioned memory is used to store a computer program, and the above-mentioned processor is used to call the above-mentioned computer program so that the computer device executes the blockchain-based data processing method in the embodiment of the present application.
[0022] On the one hand, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. The computer program is suitable for being loaded by a processor and executing the blockchain-based data processing method in the embodiment of the present application.
[0023] On the one hand, an embodiment of the present application provides a computer program product, which includes a computer program stored in a computer-readable storage medium; a processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device performs the blockchain-based data processing method in the embodiment of the present application.
[0024] In an embodiment of the present application, the business device can obtain A byte arrays by slicing the intermediate code corresponding to the smart contract; wherein A is a positive integer greater than 1, that is, the number of byte arrays is at least two; it can be seen that by slicing the intermediate code corresponding to the smart contract, the storage capacity occupied by the intermediate code corresponding to the smart contract can be dispersed into the storage capacity occupied by A byte arrays respectively. Such a decentralized method makes it possible to deploy smart contracts that occupy a larger storage capacity, which can improve the applicability of smart contract deployment. The business device can generate A program slices, each byte array corresponds to a program slice, and each program slice contains the number of the corresponding byte array, the total number of slices A and the corresponding byte array; the business device can send the A program slices to the blockchain network so that the blockchain nodes in the blockchain network can chain the A program slices; the A program slices that have been chained are used to be assembled to generate a complete intermediate code. By sending the A program slices to the blockchain node, the blockchain node can still assemble the complete intermediate code and then run the complete intermediate code (i.e., run the intermediate code corresponding to the smart contract), thereby realizing the deployment of the smart contract. It can be seen that by adopting this application, there is no limit on the storage capacity occupied by the intermediate code corresponding to the smart contract, which can improve the applicability of smart contract deployment; in addition, this application can avoid the pre-installation of the intermediate code corresponding to the smart contract on the blockchain node, and can avoid manual approval of the intermediate code corresponding to the smart contract, thereby improving the installation efficiency of the smart contract and avoiding manual approval errors. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] FIG1 is a schematic diagram of a system architecture provided by an embodiment of the present application;
[0026] FIG2 is a first schematic diagram of a blockchain-based data processing scenario provided by an embodiment of the present application;
[0027] FIG3 is a flowchart of a data processing method based on blockchain provided in an embodiment of the present application;
[0028] FIG4 is a second schematic diagram of a blockchain-based data processing scenario provided by an embodiment of the present application;
[0029] FIG5 is an interactive diagram of a blockchain-based data processing method provided in an embodiment of the present application;
[0030] FIG6 is a second flow chart of a blockchain-based data processing method provided in an embodiment of the present application;
[0031] FIG7 is a third schematic diagram of a blockchain-based data processing scenario provided by an embodiment of the present application;
[0032] FIG8 is a third flow chart of a blockchain-based data processing method provided in an embodiment of the present application;
[0033] FIG9 is a fourth flow chart of a blockchain-based data processing method provided in an embodiment of the present application;
[0034] FIG10 is a first structural diagram of a blockchain-based data processing device provided in an embodiment of the present application;
[0035] FIG11 is a second structural diagram of a blockchain-based data processing device provided in an embodiment of the present application;
[0036] FIG12 is a schematic structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] To facilitate understanding, we first provide a brief explanation of some nouns:
[0038] 1. Blockchain: In a narrow sense, blockchain is a chained data structure based on blocks. Blocks use digital summaries to verify previously acquired transaction histories, making them suitable for the tamper-proof and scalability requirements of distributed ledgers. Broadly speaking, blockchain also refers to the distributed ledger technologies implemented by blockchain structures, including distributed consensus, privacy and security protections, peer-to-peer communication technologies, network protocols, and smart contracts. The goal of blockchain is to create a distributed data record book that only allows additions, not deletions. The underlying structure of this ledger is a linear linked list. This linked list consists of a series of "blocks," with successive blocks recording the hash values of previous blocks. The legitimacy of each block (and the transactions within it) can be quickly verified by calculating the hash value. If a node in the network proposes to add a new block, the block must be confirmed through a consensus mechanism.
[0039] 2. Blockchain Nodes: Blockchain networks categorize nodes into consensus nodes (also called core nodes) and synchronization nodes (which can include data nodes and light nodes). Consensus nodes are responsible for the consensus function across the entire blockchain network; synchronization nodes are responsible for synchronizing the consensus node's ledger information, specifically the latest block data. Both consensus and synchronization nodes have internal network communication components, as blockchain networks are essentially peer-to-peer (P2P) networks, requiring P2P components to communicate with other nodes within the network. Resources and services within a blockchain network are distributed across nodes, and information transmission and service delivery occur directly between nodes, without the need for intermediaries or centralized servers (third-party) intervention.
[0040] 3. Block: A data packet carrying transaction data on a blockchain network is a data structure marked with a timestamp and the hash value of the previous block. Blocks are verified and validated through the network's consensus mechanism, confirming the transactions within them. A block consists of a block header and a block body. The block header records metadata about the current block, including the current version number, the hash value of the previous block, a timestamp, a random number, and the hash value of the Merkle root. The block body records detailed data generated over a period of time, including all verified transactions within the current block and other information generated during the block creation process. It can be considered a form of ledger. Furthermore, detailed data in the block body can include a unique Merkle root generated through the Merkle tree hashing process, which is recorded in the block header.
[0041] 4. Hash value: Also known as an information characteristic value or eigenvalue, a hash value is generated by converting input data of any length into a cryptographically encoded form and producing a fixed output using a hash algorithm. The original input data cannot be retrieved by decrypting the hash value; it is a one-way encryption function. In a blockchain, each block (except the initial block) contains the hash value of the previous block. The hash value is the core foundation and most important aspect of the potential of blockchain technology, preserving the authenticity of recorded and viewed data and the integrity of the blockchain as a whole.
[0042] 5. Public key and private key: A public key and private key are a key pair derived through an algorithm. The public key is the public portion of the key pair, while the private key is the private portion. Public keys are commonly used for encrypting data, verifying digital signatures, and other purposes. This algorithm ensures that the resulting key pair is unique. When using this key pair, if one key is used to encrypt a piece of data, the other key must be used to decrypt it. For example, data encrypted with the public key must be decrypted with the private key, and data encrypted with the private key must also be decrypted with the public key; otherwise, decryption will fail.
[0043] 6. Asymmetric Signature: A signature algorithm involves two keys: a public key (public key) and a private key (private key). The public and private keys form a pair. If data is signed with the private key, the signature can only be verified with the corresponding public key. Because the signing and verification processes use two different keys, this algorithm is called an asymmetric signature. The basic process for exchanging confidential information using an asymmetric signature is as follows: Party A generates a pair of keys and makes the public key public. When Party A needs to send a message to another party (Party B), it signs the confidential message with its private key and then sends it to Party B. Party B then verifies the signed message using Party A's public key.
[0044] 7. Smart Contract: A computer protocol designed to communicate, verify, or execute contracts in an information-based manner. In a blockchain system, a smart contract (or simply a contract) is a code that can be understood and executed by all blockchain nodes, executing arbitrary logic and producing results. In practice, smart contracts are managed and tested through transactions on the blockchain. Each transaction is equivalent to a remote procedure call (RPC) request to the blockchain system. If a smart contract is equivalent to an executable program, the blockchain is equivalent to the operating system that provides the operating environment. A blockchain can contain multiple contracts, distinguished by contract identities (IDs), identification numbers, or names.
[0045] Please refer to Figure 1, which is a schematic diagram of a system architecture provided by an embodiment of the present application. As shown in Figure 1, the system architecture may include a business server 101, a terminal device cluster, and a blockchain network.
[0046] Among them, the blockchain network may include a blockchain node cluster 10, and the blockchain node cluster 10 may include one or more blockchain nodes. The embodiment of the present application does not limit the number of blockchain nodes in the blockchain node cluster 10. As shown in Figure 1, the blockchain node cluster 10 may include blockchain node 10a, blockchain node 10b, blockchain node 10c, and blockchain node 10d. It is understood that when each blockchain node is performing normal operation, it can receive data to be uploaded to the chain (such as the program shards to be uploaded to the chain in the embodiment of the present application) sent by an off-chain device (referred to as a business device in this application, such as the business server 101 in the embodiment of the present application and the terminal device in the terminal device cluster), and generate blocks based on the received data to be uploaded to the chain, and then process the blocks on the chain. It is understood that in the specific implementation of the present application, when it involves user information (such as the intermediate code and program shards corresponding to the smart contract), when the embodiment of the present application is applied to a specific product or technology, it is necessary to obtain user permission or consent, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0047] To ensure data interoperability between blockchain nodes, data connections can exist between each blockchain node. For example, a data connection exists between blockchain node 10a and blockchain node 10c, a data connection exists between blockchain node 10a and blockchain node 10d, a data connection exists between blockchain node 10b and blockchain node 10c, and so on. It is understood that data or blocks can be transferred between blockchain nodes via these data connections. These data connections between blockchain nodes can be based on node identifiers. Each blockchain node in the blockchain network has a corresponding node identifier, and each blockchain node can store the node identifiers of other blockchain nodes with which it is connected. This allows it to subsequently broadcast acquired data or generated blocks to other blockchain nodes based on the node identifiers of other blockchain nodes. For example, blockchain node 10a can maintain a node identifier list that stores the node names and node identifiers of other blockchain nodes, as shown in Table 1.
[0048] Table 1
[0049] The node identifier can be an Internet Protocol (IP) address for interconnecting networks, or any other information that can be used to identify a node in a blockchain network. Table 1 only uses the IP address as an example for illustration.
[0050] Assuming that the node identifier of blockchain node 10a is FFFFFF, blockchain node 10a can send transaction data to blockchain node 10d through node identifier CCCCC, and blockchain node 10d can determine that the transaction data is sent by blockchain node 10a through node identifier FFFFFF; similarly, blockchain node 10d can send the block to be agreed upon to blockchain node 10c through node identifier BBBBBB, and blockchain node 10c can determine that the block to be agreed upon is sent by blockchain node 10d through node identifier CCCCCC. The same is true for data transmission between other nodes, so they will not be described one by one.
[0051] It is understandable that the above-mentioned data connection does not limit the connection method. It can be directly or indirectly connected through wired communication, directly or indirectly connected through wireless communication, or through other connection methods. This application does not limit this.
[0052] Among them, it can be understood that the blockchain node 10a, blockchain node 10b, blockchain node 10c, and blockchain node 10d shown in Figure 1 can have a one-to-one correspondence with the corresponding roles (i.e., entity objects in the corresponding business scenarios) that need to be connected to the blockchain network. The business scenarios here can specifically include electronic bill scenarios, resource issuance scenarios, resource transfer scenarios, payment scenarios, etc. At this time, the business data information in the corresponding business scenarios can specifically include electronic bill information in the electronic bill scenario, resource issuance information in the resource issuance scenario, resource transfer information in the resource transfer scenario, asset flow records in the payment scenario, etc. The specific content of the business data information in the corresponding business scenarios will not be listed one by one here.
[0053] It is understood that a terminal device cluster may include one or more terminal devices, and the embodiments of the present application do not limit the number of terminal devices in a terminal device cluster. As shown in Figure 1, a terminal device cluster may include terminal device 100a, terminal device 100b, terminal device 100c, ..., terminal device 100d. A network connection may exist between the terminal device clusters, for example, a network connection exists between terminal device 100a and terminal device 100b. At the same time, any terminal device in the terminal device cluster may have a network connection with the business server 101, for example, a network connection exists between terminal device 100d and business server 101. At the same time, any terminal device in the terminal device cluster may have a network connection with the blockchain network, for example, a network connection exists between terminal device 100b and blockchain node 10c in the blockchain network. The above-mentioned network connection does not limit the connection method and may be directly or indirectly connected via a wired network, directly or indirectly connected via a wireless network, or through other methods, and this application does not impose any restrictions on this.
[0054] It should be understood that each terminal device in the terminal device cluster shown in Figure 1 can be installed with an application client. When the application client runs in each terminal device, it can respectively exchange data with the business server 101 shown in Figure 1, that is, the aforementioned network connection; it can also exchange data with the blockchain network shown in Figure 1. Among them, the application client can be a video application, digital resource application, office software application, navigation application, shopping application, financial management application, business application, browser, etc., which has the function of obtaining source code corresponding to the smart contract. Among them, the application client can be an independent client or an embedded sub-client integrated in a client (for example, an education client and a multimedia client, etc.), which is not limited here.
[0055] Taking a digital resource application as an example, the business server 101 can be a collection of multiple servers, including the backend server and data processing server corresponding to the digital resource application. Therefore, each terminal device can transmit data with the business server 101 through the application client corresponding to the digital resource application. For example, each terminal device can upload a blockchain address creation request to the business server 101 through the application client of the digital resource application. The business server 101 can then send the blockchain address creation request to other terminal devices or transmit it to the blockchain network.
[0056] The business server 101 can be the backend server corresponding to the application client installed on the terminal devices in the terminal device cluster. It is understood that the above system can include one or more business servers, and the number of business servers is not limited here. The business server 101 shown in Figure 1 can establish a network connection with the blockchain network to facilitate data exchange with the blockchain network through the network connection.
[0057] The business device in the embodiment of the present application may include any terminal device in the terminal device cluster shown in Figure 1 and the business server 101. To facilitate subsequent understanding and explanation, the embodiment of the present application may select a device in the terminal device cluster or business server 101 shown in Figure 1 as a business device, for example, the terminal device 100c is used as the business device. When the code sharding instruction for the intermediate code corresponding to the smart contract is obtained, the business device (such as the terminal device 100c) can shard the intermediate code corresponding to the smart contract to obtain A byte arrays; it should be noted that the intermediate code and source code described in this application are both used to indicate the smart contract, and the two are different expressions of the smart contract. Among them, A is a positive integer greater than 1, and A byte arrays include byte arrays B c , c is a positive integer and c is less than or equal to A. It can be understood that the byte array B c Can represent any byte array among A byte arrays.
[0058] It can be understood that the storage capacity occupied by the byte array obtained by sharding the intermediate code corresponding to the smart contract is smaller than the storage capacity occupied by the intermediate code corresponding to the smart contract, and the larger A is, the smaller the storage capacity occupied by the byte array.
[0059] The business device can generate A program slices, each byte array corresponds to a program slice. c For example, the byte array B c Corresponding program fragment D c , where program slice D c Any program slice among A program slices can be expressed. Business equipment generates program slice D c , the program is partitioned into D c Including byte array B c Number, total number of fragments A, byte array B c and byte array B c Corresponding check code; In the embodiment of the present application, program segment D cThe storage capacity occupied is less than the block storage capacity in the blockchain. Through the above operations, the business device can generate program slices corresponding to A byte arrays, i.e., A program slices. This embodiment of the application does not describe the generation process corresponding to the number and check code. Please refer to the description of the embodiments corresponding to Figures 3 and 6 below.
[0060] Schematically, in the form of blockchain transactions, the business device divides the program into shards D c Send to the blockchain network so that the blockchain nodes in the blockchain network can shard the program D c Perform chain processing; In the embodiment of the present application, the blockchain node first stores the program slices that have passed the consensus (i.e., performs chain processing). When the total number of program slices that have been chained is A, the byte arrays included in the A program slices are assembled by the numbers included in the A program slices to obtain the complete intermediate code. For the blockchain node, the complete intermediate code needs to be verified to ensure its legitimacy. Therefore, the legitimacy of the A program slices can be verified by the check codes included in the A program slices, wherein a check code is used to determine the legitimacy of the program slice including the check code, for example: program slice D c The checksum contained in can be used to determine the program fragment D c The legitimacy of A program fragments; when it is determined that all A program fragments are legitimate, the blockchain node stores the complete intermediate code; it can be understood that the legitimacy of A program fragments can indicate that the complete intermediate code assembled from the A program fragments is the same as the intermediate code corresponding to the smart contract.
[0061] From the above, it can be seen that the embodiment of the present application can perform sharding processing on smart contract programs that are more complex to deploy and occupy a larger space (i.e., the intermediate code corresponding to the smart contract), which can improve the versatility and applicability of smart contract deployment. In addition, the embodiment of the present application sends the program shards to the blockchain node in the form of blockchain transactions, which can avoid the offline pre-installation of smart contracts in the blockchain node, and thus can avoid the installation of smart contracts on the blockchain node through manual verification, thereby improving the installation efficiency of smart contracts and avoiding errors caused by manual verification.
[0062] The methods provided in the embodiments of the present application can be executed by a computer device, including but not limited to a terminal device or a business server. A business server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud databases, cloud services, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Terminal devices include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc.
[0063] Further, please refer to Figure 2, which is a schematic diagram of a scenario of blockchain-based data processing provided by an embodiment of the present application. Among them, the implementation process of the data processing scenario can be carried out in a business server, or in a terminal device, or in a blockchain node, or interactively in a terminal device, a business server and a blockchain node, without limitation here. Among them, the terminal device can be any terminal device in the terminal device cluster of the embodiment corresponding to Figure 1 above, the business server can be the business server 101 of the embodiment corresponding to Figure 1 above, and the blockchain node can be any blockchain node in the blockchain node cluster of the embodiment corresponding to Figure 1 above. Figure 2 describes an example of implementing the embodiment of the present application with a terminal device. The embodiment of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, etc.
[0064] As shown in Figure 2, the terminal device 20a can slice the intermediate code 20b corresponding to the smart contract to obtain A byte arrays. Among them, the intermediate code 20b can be understood as bytecode. Bytecode (Byte-code) is a binary file containing an execution program and composed of a sequence of operation code (operation code, abbreviated as OP) / data pairs. It is an intermediate code. The intermediate code 20b is a syntax-oriented, equivalent internal representation code of the source program that is easy to translate into the target program. Its understandability and ease of generating target code are between the source language (i.e., source code) and the target language (i.e., target code). A byte array can be understood as a group of bytecodes. Since the intermediate code 20b can be a bytecode, the intermediate code 20b can be sliced, that is, the intermediate code 20b can be divided into A groups of bytecodes, and each group of bytecodes is called a byte array.
[0065] For ease of understanding and description, FIG2 illustrates A as 3. As shown in FIG2 , the business device 20a generates three byte arrays, namely, byte array 201c, byte array 202c, and byte array 203c. The three byte arrays are all binary arrays. For example, byte array 201c includes 00...01...11, byte array 202c includes 00...11...11, and byte array 203c includes 10...01...11. The embodiment of the present application does not limit the length of the byte array (i.e., the storage capacity occupied). The length of the byte array can be set according to the block storage capacity (i.e., the storage capacity of a block, i.e., the storage space) in the actual application scenario, for example, the length of the word array is set to be less than the block storage capacity.
[0066] It is understandable that the processing process of the three byte arrays illustrated in Figure 2 by the business device 20a is the same, so the following description is based on the processing of byte array 203c by the business device 20a as an example. Please refer to the description below for the processing process of the remaining two byte arrays, and no further details will be given. As shown in Figure 2, the business device 20a generates a number for the byte array 203c, where the number is unique and sequential, and the number can be used to indicate the order and position of the byte array in the intermediate code corresponding to the smart contract. For example: the intermediate code corresponding to the smart contract is divided into three byte arrays in sequence (the above-mentioned byte array 201c, byte array 202c, and byte array 203c), and the byte array 203c is numbered 3, indicating that the byte array 203c is the third byte array. The embodiment of the present application does not limit the expression of the number, and it can be set according to the actual application scenario. Figure 2 uses 3 as an example to illustrate the numbering of byte array 203c. Service device 20a generates a check code 201d corresponding to byte array 203c. This embodiment does not describe the generation process of the check code. Please refer to the descriptions of the embodiments corresponding to Figures 3 and 6 below. Check code 201d is a string of hash values, with Figure 2 using 3m...65..fe as an example.
[0067] Furthermore, the business device 20a can generate a program fragment corresponding to the byte array 203c (Figure 2 uses program fragment 3 as an example), which includes the number of the byte array 203c (Figure 2 uses 3 as an example), the total number of fragments A (Figure 2 uses 3 as an example), the byte array 203c, and the verification code 201d corresponding to the byte array 203c; wherein the storage capacity occupied by the program fragment 3 is less than the block storage capacity in the blockchain. Using the above process, the business device 20a can generate program fragment 1 corresponding to the byte array 201c and program fragment 2 corresponding to the byte array 202c, and the storage capacity occupied by program fragment 1 and program fragment 2, respectively, is less than the block storage capacity.
[0068] Referring again to Figure 2 , business device 20a generates a blockchain transaction 3 including program shard 3 and sends it to the blockchain network. Blockchain node 20e in the blockchain network receives the blockchain transaction 3 (including program shard 3) sent by business device 20a. Blockchain node 20e then uploads program shard 3 to the blockchain. Similarly, business device 20a also sends program shard 1 and program shard 2 to the blockchain network, and blockchain nodes in the blockchain network (including blockchain node 20e) also upload program shard 1 and program shard 2 to the blockchain network. Specifically, as shown in Figure 2 , blockchain node 20e belongs to blockchain 201f, and blockchain node 20e packages blockchain transaction 3 into block 20g to be uploaded. Blockchain node 20e broadcasts the block to be chained 20g to other blockchain nodes, so other blockchain nodes can also perform consensus processing on the block to be chained 20g and generate a consensus result. If the consensus result of the blockchain network for the block to be chained 20g is a consensus passing result, then blockchain node 20e can store the block to be chained 20g, that is, add it to blockchain 201f to obtain blockchain 202f.
[0069] Blockchain node 20g determines the number of program shards that have been uploaded to the chain. When the total number of program shards that have been uploaded to the chain is A (i.e., 3), blockchain node 20e can assemble the byte arrays included in each of the three program shards using the serial numbers included in each of the three program shards to obtain a complete intermediate code. In one implementation, blockchain node 20e can perform a validity check on program shard 3 using the check code 201d included in program shard 3 to determine the validity of program shard 3. Similarly, blockchain node 20e can perform a validity check on program shard 1 using the check code included in program shard 1 to determine the validity of program shard 1. Blockchain node 20e can perform a validity check on program shard 2 using the check code included in program shard 2 to determine the validity of program shard 2. If all three program fragments are valid, the blockchain node stores the complete intermediate code. It can be understood that the validity of all three program fragments indicates that the complete intermediate code assembled from the three program fragments is the same as the intermediate code 20b corresponding to the smart contract.
[0070] From the above, it can be seen that when the storage capacity occupied by the intermediate code corresponding to the smart contract is greater than or equal to the block storage capacity, by sharding the intermediate code corresponding to the smart contract, the storage capacity occupied by the intermediate code corresponding to the smart contract can be dispersed into the storage capacity occupied by A byte arrays respectively. This dispersion method makes it possible to deploy smart contracts that occupy a larger storage capacity, which can improve the applicability of smart contract deployment. By sending A program fragments corresponding to A byte arrays to the blockchain node, the blockchain node can assemble a complete intermediate code and then run the complete intermediate code (that is, run the intermediate code corresponding to the smart contract). Therefore, by adopting this application, there is no limit on the storage capacity occupied by the intermediate code corresponding to the smart contract, which can improve the applicability of smart contract deployment. In addition, this application can avoid pre-installing the intermediate code corresponding to the smart contract on the blockchain node, avoid manual approval of the intermediate code corresponding to the smart contract, thereby improving the installation efficiency of the smart contract and avoiding manual approval errors.
[0071] Further, please refer to Figure 3, which is a flowchart illustrating a blockchain-based data processing method provided in an embodiment of the present application. This embodiment of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, and assisted driving. The data processing method can be executed by a service device, which can be the service server 101 in the system architecture described in Figure 1, any terminal device in a terminal device cluster, or both the service server 101 and the terminal device. As shown in Figure 3, the data processing method can include at least the following steps S101-S103.
[0072] Step S101: Slice the intermediate code corresponding to the smart contract to obtain A byte arrays; A is a positive integer greater than 1; A byte arrays include byte array B c , c is a positive integer and c is less than or equal to A.
[0073] Specifically, the source code corresponding to the smart contract is encoded to obtain the intermediate code corresponding to the smart contract, and the storage capacity occupied by the intermediate code corresponding to the smart contract is obtained; the block storage capacity is obtained, and the storage capacity occupied by the intermediate code corresponding to the smart contract is compared with the block storage capacity; the block storage capacity is used to represent the storage capacity of a block in the blockchain; if the storage capacity occupied by the intermediate code corresponding to the smart contract is equal to or greater than the block storage capacity, the intermediate code corresponding to the smart contract is sharded according to the block storage capacity to obtain A byte arrays.
[0074] To implement business functions such as resource transfer, resource query, and resource destruction, device objects (e.g., developers) can input or retrieve the source code corresponding to the smart contract on the business device in various languages. Source code (also known as source program) refers to uncompiled text files written in a specific programming language specification and is a series of human-readable computer language instructions. To translate this human-readable text (i.e., source code) into binary instructions executable by computers (including blockchain nodes), the business device can encode the source code corresponding to the smart contract to obtain the intermediate code corresponding to the smart contract.
[0075] The embodiments of this application do not restrict the use of smart contracts and can be set according to actual application scenarios. Therefore, there are no restrictions on the language and content of the source code, nor on the encoding method or the content of the intermediate code. Among them, the encoding method includes but is not limited to compilation and packaging. Compilation can convert high-level languages into binary language that computers can understand. Computers only understand 1s and 0s. The compiler converts the language that people are familiar with into binary language.
[0076] This solution is suitable for deploying larger smart contracts within a blockchain system. A larger smart contract is one that occupies a larger space. Specifically, it means the storage capacity occupied by the intermediate code corresponding to the smart contract is greater than or equal to the block storage capacity. This solution can be implemented through hardware, software, or a combination of hardware and software. The specific implementation process is as follows: the service device obtains the storage capacity occupied by the intermediate code corresponding to the smart contract, i.e., the space occupied by the intermediate code corresponding to the smart contract; and obtains the block storage capacity, i.e., the storage capacity of a block in the blockchain. As you can see, to ensure blockchain security, consensus on blocks must be reached quickly, so block size (i.e., storage capacity) is limited. For example, the size of a block is 1 megabyte (MB), which limits the size of smart contracts. The business device compares the storage capacity occupied by the intermediate code corresponding to the smart contract with the block storage capacity. If the storage capacity occupied by the intermediate code corresponding to the smart contract is smaller than the block storage capacity, for example, the storage capacity occupied by the intermediate code corresponding to the smart contract is 10 kilobytes (KB) and the block storage capacity is 1MB, since the storage capacity occupied by the intermediate code corresponding to the smart contract is smaller than the block storage capacity, the business device can send the intermediate code corresponding to the smart contract as a blockchain transaction to the blockchain network. The processing process of the blockchain transaction by the blockchain node in the blockchain network is the same as the processing process of using program shards as blockchain transactions below, which will not be repeated here.
[0077] For another example, the storage capacity occupied by the intermediate code corresponding to the smart contract is 1MB, and the block storage capacity is 1MB. In this case, the storage capacity occupied by the intermediate code corresponding to the smart contract is equal to the block storage capacity. Since the block not only records detailed blockchain transactions in the block body, but also needs to record the parent block hash value and the hash value of the current block in the block header, the intermediate code corresponding to the smart contract cannot be directly packaged into the block. In order to solve the above problem, according to the block storage capacity, the business device can shard the intermediate code corresponding to the smart contract to obtain A byte arrays. It is understandable that the above sharding process is performed in byte order. Please refer to Figure 4, which is a second schematic diagram of a scenario of blockchain-based data processing provided in an embodiment of the present application. As shown in Figure 4, the intermediate code 30a corresponding to the smart contract can be 00...01...1100...11...1110...01...11. The business device fragments the intermediate code 30a in sequence to obtain 3 (that is, example A is 3) byte arrays. The first byte array is byte array 301b, including 00...01...11, and the byte array 301b is numbered 1; the second byte array is byte array 302b, including 00...11...11, and the byte array 302b is numbered 2; the third byte array is byte array 303b, including 10...01...11, and the byte array 303b is numbered 3.
[0078] Step S102 : Generate A program slices according to the number of each byte array, the total number of slices A and the byte array, where each byte array corresponds to one program slice.
[0079] Byte array A includes byte array B c , with byte array B c For example, according to the byte array B c Number, total number of fragments A and byte array B c , generate program fragment D c .
[0080] Specifically, according to the byte array B c Generate byte array B at array position in byte array A c Corresponding number; determine the verification range, according to the verification range, determine the byte array A with byte array B c The associated byte array includes one or more byte arrays; the number corresponding to the associated byte array, the total number of slices A, and the associated byte array are concatenated to obtain an associated slice data structure; the check code corresponding to the associated slice data structure is determined as byte array B c Corresponding check code; according to byte array B cNumber, total number of fragments A, byte array B c and byte array B c The corresponding check code generates program fragment D c .
[0081] Among them, according to the verification range, determine the byte array A and the byte array B c The specific process of associating the byte arrays may include: if the check range is the check fragment range, then in the A byte array, the byte array B c Determine the byte array B c The associated byte array; then the number corresponding to the associated byte array, the total number of fragments A and the associated byte array are spliced together to obtain the associated fragment data structure. The specific process may include: c Corresponding number, total number of fragments A and byte array B c Perform splicing processing to obtain the associated shard data structure.
[0082] Specifically, the associated shard data structure is hashed to obtain a hash value of the associated shard data structure, and the hash value is determined as the verification code of the associated shard data structure; or the device private key of the business device is obtained, and the associated shard data structure is signed using the device private key to obtain a signature value of the associated shard data structure, and the signature value is determined as the verification code of the associated shard data structure.
[0083] Based on the array position of each byte array within the A byte arrays, the service device can generate a corresponding number for each byte array. Referring again to Figure 4 , byte array 301b is the first byte array, so its number 301c can be 1. Byte array 302b is the second byte array, so its number 302c can be 2. Byte array 303b is the third byte array, so its number 303c can be 3. It can be understood that in the example of Figure 4 , A = 3, the total number of slices 30d is 3.
[0084] This application can provide three types of verification ranges, namely, verification slice range, verification group range and verification overall range. Among them, the verification slice range means that when the blockchain node verifies the legitimacy of A program slices, it verifies the program slices one by one. The verification group range means that when verifying the legitimacy of A program slices, the blockchain node verifies multiple groups of program slices separately. Usually, each group of program slices includes multiple program slices, and the program slices within the group are sorted according to the array position, and the groups are also sorted according to the array position. The verification overall range means that when verifying the legitimacy of A program slices, the blockchain node verifies all program slices (i.e., A program slices) together.
[0085] The embodiment of the present application first describes the verification fragment range. Please refer to Figure 4 again. If the verification range is the verification fragment range, then the business device determines byte array 301b as the associated byte array associated with byte array 301b, byte array 302b as the associated byte array associated with byte array 302b, and byte array 303b as the associated byte array associated with byte array 303b among the three byte arrays. The business device concatenates the number 301c corresponding to byte array 301b (such as 1 in the example of Figure 4), the total number of fragments A (such as 3 in the example of Figure 4), and byte array 301b to obtain the associated fragment data structure corresponding to byte array 301b. Similarly, the business device concatenates the number 302c corresponding to the byte array 302b (as shown in the example of 2 in Figure 4), the total number of fragments A and the byte array 302b to obtain the associated fragment data structure corresponding to the byte array 302b; the business device concatenates the number 303c corresponding to the byte array 303b (as shown in the example of 3 in Figure 4), the total number of fragments A and the byte array 303b to obtain the associated fragment data structure 30e corresponding to the byte array 303b, which is 3310...01...11 in the example of Figure 4.
[0086] Among them, according to the verification group range, the service device determines the byte array A and the byte array B c The associated byte array, and based on the overall verification range, the business device determines the byte array A with the byte array B c The process of associating the byte arrays is not described in the present embodiment of the application. Please refer to the description of the embodiment corresponding to Figure 6 below.
[0087] The business device determines the check codes corresponding to A associated shard data structures. The embodiment of the present application does not limit the method for determining the check code, and any method with a check function is acceptable. For example, the business device can perform an encryption operation, i.e., a hash operation, on the associated shard data structure through a cryptographic algorithm to obtain a hash value of the associated shard data structure, and determine the hash value as the check code of the associated shard data structure. As shown in Figure 4, the business device performs a hash process on the associated shard data structure 30e to obtain a hash value 30f, i.e., 3m...65..fe in Figure 4. Similarly, the business device can obtain the hash value corresponding to the byte array 301b and the hash value corresponding to the byte array 302b. The embodiment of the present application does not limit the cryptographic algorithm, and the cryptographic algorithm can be obtained according to the actual application scenario.
[0088] Optionally, the service device obtains a device private key, uses the device private key to sign the associated shard data structure, obtains a signature value of the associated shard data structure, and uses the signature value as a verification code of the associated shard data structure. The device private key refers to the private key of the service device.
[0089] Further, as shown in Figure 4, the business device generates a program fragment 3, which includes the number 303c of the byte array 303b, the total number of fragments A, the byte array 303b, and the check code 30f corresponding to the byte array 303b; similarly, the business device can generate a program fragment 1, which includes the number 301c (i.e., 1) of the byte array 301b, the total number of fragments A, the byte array 301b, and the check code corresponding to the byte array 301b; and can generate a program fragment 2, which includes the number 302c (i.e., 2) of the byte array 302b, the total number of fragments A, the byte array 302b, and the check code corresponding to the byte array 302b.
[0090] Combining steps S101 and S102, it can be seen that for smart contract programs (i.e., intermediate codes) that take up a large amount of space, the embodiment of the present application can divide the intermediate codes corresponding to the smart contract into multiple program fragments through fragmentation processing technology. Each program fragment consists of four parts: number, total number of fragments, byte array, and check code, where: the number indicates the position of the program fragment in the complete contract program; the total number of fragments A indicates how many program fragments the complete contract program consists of, which is used for subsequent program fragment assembly inspection. The byte array in the program fragment is a partial contract program, which is used to assemble a complete contract program; the check code is used to perform integrity verification on the program fragment to ensure that the program fragment will not be tampered with during transmission.
[0091] The embodiment of the present application does not limit the size of the program shards. The size of each program shard needs to be set according to the actual situation. It is related to the transaction size limit and block size limit of the blockchain system. The program shards need to ensure that the storage space they occupy is less than the above limits.
[0092] As can be seen from the above, the embodiment of the present application provides a smart contract sharding deployment solution. Through this technical solution, it is possible to deploy more complex smart contracts that occupy a large storage space without changing the block size limit.
[0093] In step S103, the A program fragments are sent to the blockchain network so that the blockchain nodes in the blockchain network can process the A program fragments on the chain; the A program fragments that have been on the chain are used to be assembled to generate a complete intermediate code.
[0094] Specifically, in the form of blockchain transactions, the business device sends A program shards to the blockchain network. It can be understood that if there are A byte arrays, the business device will generate A program shards, and then send A blockchain transactions to the blockchain network, that is, one program shard corresponds to one blockchain transaction.
[0095] One feasible implementation is as follows: To reduce storage space usage, the business device can compress each of the A program shards to obtain A program shard compressed packages; these A program shard compressed packages are then sent to the blockchain network via blockchain transactions. Similarly, each program shard compressed package corresponds to one blockchain transaction. In this scenario, if all A program shard compressed packages are successfully uploaded to the blockchain and the blockchain node obtains the A program shard compressed packages, the A program shard compressed packages can be decompressed to obtain A program shards. The subsequent processing is the same as described above and will not be repeated here.
[0096] Please refer to Figure 5 for the above process, which is an interactive diagram of a blockchain-based data processing method provided by an embodiment of the present application. As shown in Figure 5, the method includes the following steps.
[0097] Step A: The business device encodes the smart contract program to obtain the intermediate code corresponding to the smart contract.
[0098] Specifically, encoding methods include, but are not limited to, compilation, packaging, or both. A smart contract program refers to the source code corresponding to a smart contract.
[0099] Step B: The business device shards the intermediate code corresponding to the smart contract to form multiple program shards.
[0100] Specifically, the business equipment uses a sharding processing tool to shard the intermediate code corresponding to the smart contract. Each program shard has a unique number, and the size of the program shard is smaller than the block limit so that it can be successfully packaged into the block and processed by consensus.
[0101] Step C: The business device sends multiple program shards to the blockchain node through blockchain transactions.
[0102] Specifically, a blockchain application can be installed on the business device. Through the blockchain application, the program shards are sent to the blockchain node in the form of blockchain transactions. The blockchain node packages the received program shards into blocks and performs consensus processing. After the consensus is passed, the program shards are stored in the local ledger.
[0103] Step D: The blockchain node assembles multiple program fragments to generate complete intermediate code.
[0104] Specifically, after receiving all the program shards, the blockchain node sorts the program shards according to their unique numbers, and then assembles the complete intermediate code, i.e., the complete intermediate code, in sequence.
[0105] Step E: perform integrity checks on multiple program slices respectively.
[0106] Specifically, the blockchain node uses an integrity verification algorithm to perform integrity verification on A program shards respectively. If all A program shards pass the verification, the blockchain node proceeds to the next step. If any program shard fails the verification, the program shard that fails the verification is discarded and waits for a new program shard.
[0107] Step F: When multiple program segments pass verification, the complete intermediate code is stored.
[0108] Specifically, the storage of the complete intermediate code is off-chain, that is, it does not need to be packaged into blocks for on-chain processing.
[0109] From the above, it can be seen that when the storage capacity occupied by the intermediate code corresponding to the smart contract is greater than or equal to the block storage capacity, by sharding the intermediate code corresponding to the smart contract, the storage capacity occupied by the intermediate code corresponding to the smart contract can be dispersed into the storage capacity occupied by A byte arrays respectively. This dispersion method makes it possible to deploy smart contracts that occupy a larger storage capacity, which can improve the applicability of smart contract deployment. By sending A program fragments corresponding to A byte arrays to the blockchain node, the blockchain node can assemble a complete intermediate code and then run the complete intermediate code (that is, run the intermediate code corresponding to the smart contract). Therefore, by adopting this application, there is no limit on the storage capacity occupied by the intermediate code corresponding to the smart contract, which can improve the applicability of smart contract deployment. In addition, this application can avoid pre-installing the intermediate code corresponding to the smart contract on the blockchain node, avoid manual approval of the intermediate code corresponding to the smart contract, thereby improving the installation efficiency of the smart contract and avoiding manual approval errors.
[0110] Please refer to Figure 6, which is a flow chart of a data processing method provided by an embodiment of the present application. The method can be executed by a business server (for example, the business server 101 shown in Figure 1 above), or by a terminal device (for example, the terminal device 100a shown in Figure 1 above), or by a blockchain node (for example, the blockchain node 10a illustrated in Figure 1 above), or interactively executed by any two or three devices among the business server, terminal device, and blockchain node. For ease of understanding, the embodiment of the present application is described by taking the method as being executed by a business device (specifically a business server or terminal device or a business server and a terminal device) as an example. As shown in Figure 6, the method may at least include the following steps S201-step S207.
[0111] Step S201: Slice the intermediate code corresponding to the smart contract to obtain A byte arrays; A is a positive integer greater than 1; A byte arrays include byte array B c , c is a positive integer and c is less than or equal to A.
[0112] Step S202, according to byte array B c Generate byte array B at array position in byte array A c The corresponding number.
[0113] For the specific implementation process of step S201-step S202, please refer to the description of step S101-step S102 in the embodiment corresponding to FIG3 above, which will not be repeated here.
[0114] Step S203, determine the verification range, and determine the byte arrays A and B according to the verification range. c The associated associative byte array; an associative byte array contains one or more byte arrays.
[0115] In one embodiment, if the verification range is a verification group range, the A byte arrays are grouped according to the array positions corresponding to the A byte arrays to obtain E byte array sets; E is a positive integer greater than 1, and E is less than A; in the E byte array sets, the byte array B is included. c The byte array collection is determined to be the same as the byte array B c The associated associative byte array.
[0116] In another embodiment, if the verification range is the entire verification range, the A byte arrays are determined to be the same as the byte array B. c The associated associative byte array.
[0117] The embodiment corresponding to FIG3 above describes a scenario where the verification range is the verification shard range. This step describes the verification group range and the verification overall range. Please also refer to FIG7, which is a schematic diagram of a third scenario of blockchain-based data processing provided by an embodiment of the present application. As shown in FIG7, in this step example, A is equal to 4, that is, the business device generates four byte arrays, namely byte array 1, byte array 2, byte array 3, and byte array 4. Among them, byte array 1 is ranked first among the four byte arrays, so its number 601a can be set to 1, byte array 2 is ranked second among the four byte arrays, so its number 602a can be set to 2, byte array 3 is ranked third among the four byte arrays, so its number can be set to 3, and byte array 4 is ranked fourth among the four byte arrays, so its number can be set to 4; obviously, the total number of shards is 4.
[0118] If the verification range is the verification group range, the service device groups the four byte arrays according to their corresponding array positions, obtaining E byte array sets, as shown in FIG7 . In this example, E is equal to 2. The service device groups byte arrays 1 and 2 into the first byte array set, and groups byte arrays 3 and 4 into the second byte array set. It is understood that E is less than A. If E is equal to A, then the verification range is the verification fragment range.
[0119] Please refer to Figure 7 again. Among the two byte array sets, the business device will determine the byte array set including byte array 1 (i.e., the first byte array set mentioned above) as the associated byte array associated with byte array 1; the byte array set including byte array 2 (i.e., the first byte array set mentioned above) as the associated byte array associated with byte array 2; the byte array set including byte array 3 (i.e., the second byte array set mentioned above) as the associated byte array associated with byte array 3; and the business device will determine the byte array set including byte array 4 (i.e., the second byte array set mentioned above) as the associated byte array associated with byte array 4.
[0120] Please refer to Figure 7 again. If the verification range is the entire verification range, the business device will determine the four byte arrays in Figure 7 as associated byte arrays associated with byte array 1; the four byte arrays in Figure 7 will be determined as associated byte arrays associated with byte array 2; the four byte arrays in Figure 7 will be determined as associated byte arrays associated with byte array 3; and the four byte arrays in Figure 7 will be determined as associated byte arrays associated with byte array 4.
[0121] Step S204 , concatenating the serial number corresponding to the associated byte array, the total number of slices A, and the associated byte array to obtain an associated slice data structure.
[0122] In one embodiment, if the check range is a check group range, including byte array B c The byte array set contains F byte arrays; then the F byte arrays can be obtained; F is a positive integer, and F is less than A; the numbers corresponding to the F byte arrays, the total number of fragments A and the F byte arrays are spliced to obtain an associated fragment data structure.
[0123] In another embodiment, if the verification range is the entire verification range, the numbers corresponding to the A byte arrays, the total number of fragments A, and the A byte arrays are concatenated to obtain an associated fragment data structure.
[0124] Referring again to Figure 7 , if the verification range is the verification group range, the service device concatenates the number 601a corresponding to byte array 1, the number 602a corresponding to byte array 2, the total number of fragments 60b, byte array 1, and byte array 2 to obtain an associated fragment data structure corresponding to both byte array 1 and byte array 2. Figure 7 uses fragment data structure 1 as an example. Similarly, the service device concatenates the number corresponding to byte array 3, the number corresponding to byte array 4, the total number of fragments 60b, byte array 3, and byte array 4 to obtain an associated fragment data structure corresponding to both byte array 3 and byte array 4.
[0125] If the verification range is the entire verification range, the business device concatenates the number 601a corresponding to byte array 1, the number 602a corresponding to byte array 2, the number corresponding to byte array 3, the number corresponding to byte array 4, the total number of fragments 60b, byte array 1, byte array 2, byte array 3, and byte array 4 to obtain an associated fragment data structure. It can be understood that byte array 1, byte array 2, byte array 3, and byte array 4 all correspond to the same associated fragment data structure.
[0126] Step S205: Determine the check code corresponding to the associated fragment data structure as byte array B c The corresponding check code.
[0127] Step S206, according to the byte array B c Number, total number of fragments A and byte array B c , generate program fragment D c ; Program fragment D c The storage capacity occupied is smaller than the block storage capacity in the blockchain.
[0128] Step S207, sending the program slices corresponding to the A byte arrays to the blockchain network, so that the blockchain nodes in the blockchain network can process the A program slices on the chain; the A program slices that have been on the chain are used to be assembled to generate a complete intermediate code; the complete intermediate code is used to store when the blockchain node determines that the A program slices are all legitimate through the verification codes respectively included in the A program slices; wherein, a verification code is used to determine the legitimacy of the program slice including the verification code; the legitimacy of the A program slices is used to indicate that the complete intermediate code assembled by the A program slices is the same as the intermediate code corresponding to the smart contract.
[0129] For the specific implementation process of steps S205 to S207, please refer to the description of steps S102 to S103 in the embodiment corresponding to FIG3 above, which will not be repeated here.
[0130] From the above, it can be seen that when the storage capacity occupied by the intermediate code corresponding to the smart contract is greater than or equal to the block storage capacity, by sharding the intermediate code corresponding to the smart contract, the storage capacity occupied by the intermediate code corresponding to the smart contract can be dispersed into the storage capacity occupied by A byte arrays respectively. This dispersion method makes it possible to deploy smart contracts that occupy a larger storage capacity, which can improve the applicability of smart contract deployment. By sending A program fragments corresponding to A byte arrays to the blockchain node, the blockchain node can still assemble a complete intermediate code and then run the complete intermediate code (that is, run the intermediate code corresponding to the smart contract). Therefore, by adopting this application, there is no limit on the storage capacity occupied by the intermediate code corresponding to the smart contract, which can improve the applicability of smart contract deployment. In addition, this application can avoid pre-installing the intermediate code corresponding to the smart contract on the blockchain node, avoid manual approval of the intermediate code corresponding to the smart contract, thereby improving the installation efficiency of the smart contract and avoiding manual approval errors.
[0131] Further, please refer to Figure 8, which is a flow chart of a data processing method provided by an embodiment of the present application. The method can be executed by a business server (for example, the business server 101 shown in Figure 1 above), or by a terminal device (for example, the terminal device 100a shown in Figure 1 above), or by a blockchain node (for example, the blockchain node 10a illustrated in Figure 1 above), or interactively executed by any two or three devices among the business server, terminal device, and blockchain node. For ease of understanding, the embodiment of the present application is described by taking the method being executed by a blockchain node as an example. As shown in Figure 8, the method may at least include the following steps S301-S302.
[0132] Step S301: Obtain program shards initiated by the business device and uploaded to the chain, and obtain the total number of shards A in the uploaded program shards; A is a positive integer greater than 1; the business device is used to shard the intermediate code corresponding to the smart contract to obtain A byte arrays; each byte array corresponds to a program shard.
[0133] Specifically, the program shards initiated by the business device are obtained, and the program shards are packaged into the block to be chained; the block to be chained is subjected to consensus processing to obtain a consensus result. If the consensus result is a consensus passing result, the block to be chained is subjected to chain processing; if the block to be chained is successfully chained, the program shards are determined to be the program shards that have been chained, and the program shards that have been chained are obtained.
[0134] Program shards sent by business devices are stored on-chain by blockchain nodes, that is, packaged into blocks. One feasible approach is to use blockchain transactions, in which case A program shards are stored on all relevant blockchain nodes. Another feasible approach is to use program shard routing, in which case A program shards are only stored on a subset of blockchain nodes. In both of these feasible approaches, all relevant blockchain nodes or a subset of relevant blockchain nodes can store all program shards.
[0135] Another feasible way is to store different program shards for different blockchain nodes. For example, there are three program shards in total. Among them, program shard 1 is packaged into block 1 by blockchain node 1. When the consensus of block 1 is passed, only blockchain node 1 stores program shard 1 in the local ledger; program shard 2 is packaged into block 2 by blockchain node 2. When the consensus of block 2 is passed, only blockchain node 2 stores program shard 2 in the local ledger; program shard 3 is packaged into block 3 by blockchain node 3. When the consensus of block 3 is passed, only blockchain node 3 stores program shard 3 in the local ledger. At this time, the blockchain node may store some program shards, but blockchain node 1 can send a first transaction synchronization request to blockchain node 2 to request blockchain node 2 to synchronize program shard 2, so blockchain node 1 can obtain the program shard 2 that has been on the chain; similarly, blockchain node 1 can send a second transaction synchronization request to blockchain node 3 to request blockchain node 3 to synchronize program shard 3, so blockchain node 1 can obtain the program shard 3 that has been on the chain. At this time, blockchain node 1 can implement the embodiment of the present application. Similarly, the above-mentioned blockchain node 2 and blockchain node 3 can also send transaction synchronization requests for synchronizing program shards to other blockchain nodes.
[0136] Step S302: Count the total number of program segments that have been chained. If the total number is equal to the total number of segments A, assemble the byte arrays included in the A program segments according to the numbers included in the A program segments to obtain the complete intermediate code.
[0137] Please also refer to Figure 9, which is a flowchart diagram of a blockchain-based data processing method provided in an embodiment of the present application. As shown in Figure 9, the method includes steps S3021 to S3023.
[0138] Step S3021: Obtain program fragments.
[0139] Specifically, the embodiment of the present application does not limit the way in which the blockchain node obtains the program shards. Please refer to the description of step S301 above. The program shards sent by the business device in the form of blockchain transactions can be obtained, and the program shards that have been on the chain can also be synchronized to other blockchain nodes.
[0140] Step S3022: Whether the total number of program slices obtained is equal to the total number of slices A.
[0141] Specifically, each time a blockchain node receives a program shard, it will check the number of program shards. If the total number of program shards received is equal to the total number of shards A specified by the program shard, it indicates that all program shards have been received, so program assembly can be performed.
[0142] Step S3023: extract the byte arrays respectively included in the A program slices, arrange them according to the numbers, and obtain the complete intermediate code.
[0143] Specifically, smart contract programs (i.e., the intermediate code corresponding to the smart contract) are fragmented by number. However, the program fragments received by blockchain nodes may be out of order. Therefore, the byte arrays of the program fragments must be sorted by number to assemble the complete intermediate code. The blockchain node stores the assembled complete intermediate code for subsequent decoding, calling, and querying.
[0144] The above method also includes the following content: A program slices include program slice G h , h is a positive integer, and h is less than or equal to A; according to the program segment G h Included checksum, program fragment G h Perform a legality check and obtain the verification result I h .
[0145] Specifically, determine the verification range, and determine the program slice G in the A program slices according to the verification range. h The associated program slices; the associated program slices include one or more program slices; the numbers of the associated program slices, the total number of slices A and the byte arrays included in the associated program slices are spliced to obtain the slice data structure to be checked; according to the slice data structure to be checked and the program slice G h Included check code, determine the check result I h .
[0146] Among them, according to the verification range, determine the program slice G in A program slices h The specific process of associating the associated program slices may include: if the verification range is the verification slice range, then among the A program slices, the program slice G h Determined to be with program shard G h Associated associated program slices; if the verification range is the entire verification range, then A program slices are determined to be associated with program slice G h Associated associated program slices; if the verification range is the verification group range, then obtain the program slice G hThe number group carried by the included check code; the number group includes one or more numbers, and the number group includes program fragment G h In the A program slices, the program slice corresponding to the number group is determined to be the same as the program slice G h The associated associated program slice.
[0147] Among them, according to the data structure of the slice to be verified and the program slice G h Included check code, determine the check result I h The specific process may include: if the program is segmented G h If the check code is a hash value, the data structure of the slice to be checked is hashed to obtain the hash value to be checked; the hash value to be checked and the program slice G are combined. h Compare the included checksums; if the hash value to be checked and the program fragment G h If the check codes included are the same, the check result is determined as the check result I h ; If the hash value and program fragment G are to be verified h If the verification code included is different, the verification failure result is determined as the verification result I h .
[0148] Among them, according to the data structure of the slice to be verified and the program slice G h Included check code, determine the check result I h The specific process may include: if the program is segmented G h If the included check code is a signature value, the device public key of the business device is obtained; through the device public key, the program is segmented into G h The included verification code is processed to obtain the verification result; if the verification result is a successful verification result, the verification result is determined as the verification result I h If the signature verification result is a signature verification failure result, the verification failure result is determined as the verification result I h .
[0149] The above method also includes the following content: if the verification results corresponding to A program slices are all verification-passing results, then the complete intermediate code is stored; A verification results are all verification-passing results, which is used to indicate that the complete intermediate code is the same as the intermediate code corresponding to the smart contract.
[0150] From the above, it can be seen that when the storage capacity occupied by the intermediate code corresponding to the smart contract is greater than or equal to the block storage capacity, by sharding the intermediate code corresponding to the smart contract, the storage capacity occupied by the intermediate code corresponding to the smart contract can be dispersed into the storage capacity occupied by A byte arrays respectively. This dispersion method makes it possible to deploy smart contracts that occupy a larger storage capacity, which can improve the applicability of smart contract deployment. By sending A program fragments corresponding to A byte arrays to the blockchain node, the blockchain node can still assemble a complete intermediate code and then run the complete intermediate code (that is, run the intermediate code corresponding to the smart contract). Therefore, by adopting this application, there is no limit on the storage capacity occupied by the intermediate code corresponding to the smart contract, which can improve the applicability of smart contract deployment. In addition, this application can avoid pre-installing the intermediate code corresponding to the smart contract on the blockchain node, avoid manual approval of the intermediate code corresponding to the smart contract, thereby improving the installation efficiency of the smart contract and avoiding manual approval errors.
[0151] Please refer to Figure 10, which is a structural schematic diagram of a blockchain-based data processing device provided in an embodiment of the present application. As shown in Figure 10, the blockchain-based data processing device 1 can run on a computer device, which can be a business device. The above-mentioned blockchain-based data processing device 1 can be a computer program (including program code) running on a computer device, for example, the data processing device is an application software; the data processing device can be used to execute the corresponding steps of the method provided in the embodiment of the present application. As shown in Figure 10, the blockchain-based data processing device 1 can include: a code processing module 11, a shard generation module 12, and a shard sending module 13.
[0152] The code processing module 11 is used to slice the intermediate code corresponding to the smart contract to obtain A byte arrays;
[0153] A fragment generation module 12 is configured to generate A program fragments according to the number of each byte array, the total number of fragments A, and each byte array, wherein each byte array corresponds to one program fragment;
[0154] The fragment sending module 13 is used to send the A program fragments to the blockchain network so that the blockchain nodes in the blockchain network can process the A program fragments on the chain; the A program fragments that have been on the chain are used to be assembled to generate a complete intermediate code.
[0155] The specific functional implementation of the code processing module 11, the fragment generation module 12 and the fragment sending module 13 can be found in steps S101 to S103 in the embodiment corresponding to FIG3 above, and will not be repeated here.
[0156] Referring again to FIG. 10 , the code processing module 11 may include: a first processing unit 111 , a first acquiring unit 112 , and a second processing unit 113 .
[0157] The first processing unit 111 is configured to encode the source code corresponding to the smart contract to obtain the intermediate code corresponding to the smart contract and obtain the storage capacity occupied by the intermediate code corresponding to the smart contract;
[0158] The first acquisition unit 112 is configured to obtain the block storage capacity by comparing the storage capacity occupied by the intermediate code corresponding to the smart contract with the block storage capacity; the block storage capacity is used to represent the storage capacity of a block in the blockchain;
[0159] The second processing unit 113 is configured to fragment the intermediate code corresponding to the smart contract according to the block storage capacity to obtain A byte arrays if the storage capacity occupied by the intermediate code corresponding to the smart contract is equal to or greater than the block storage capacity.
[0160] The specific functional implementation of the first processing unit 111 , the first acquiring unit 112 and the second processing unit 113 can be found in step S101 in the embodiment corresponding to FIG3 , which will not be described in detail here.
[0161] Please refer to Figure 10 again, byte array A includes byte array B c , byte array B c Corresponding program fragment D c , c is a positive integer and c is less than or equal to A; the fragment generation module 12 may include: a first generation unit 121, a first determination unit 122, a third processing unit 123 and a second determination unit 124.
[0162] The first generating unit 121 is used to generate a byte array B c Generate byte array B at array position in byte array A c Corresponding number;
[0163] The first determining unit 122 is used to determine the verification range, and determine the byte arrays A and B according to the verification range. c an associated associative byte array; an associative byte array comprises one or more byte arrays;
[0164] The third processing unit 123 is configured to concatenate the serial number corresponding to the associated byte array, the total number of fragments A, and the associated byte array to obtain an associated fragment data structure;
[0165] The second determining unit 124 is configured to determine the check code corresponding to the associated fragment data structure as a byte array B c The corresponding check code.
[0166] Among them, the specific functional implementation of the first generating unit 121, the first determining unit 122, the third processing unit 123 and the second determining unit 124 can refer to steps S202 to S205 in the embodiment corresponding to Figure 6 above, and will not be repeated here.
[0167] Please refer to FIG. 10 again, the first determining unit 122 may include: a first determining subunit 1221 .
[0168] The first determining subunit 1221 is configured to, if the verification range is the verification fragment range, convert the byte array B into the A byte arrays. c Determine the byte array B c the associated associative byte array;
[0169] The third processing unit 123 may include: a first processing sub-unit 1231 .
[0170] The first processing sub-unit 1231 is used to process the byte array B c Corresponding number, total number of fragments A and byte array B c Perform splicing processing to obtain the associated shard data structure.
[0171] The specific functional implementation of the first determining subunit 1221 and the first processing subunit 1231 can be found in steps S203 to S204 in the embodiment corresponding to FIG6 , and will not be described in detail here.
[0172] Please refer to FIG. 10 again, the first determining unit 122 may include: a second processing subunit 1222 and a second determining subunit 1223 .
[0173] The second processing sub-unit 1222 is configured to, if the verification range is a verification group range, group the A byte arrays according to the array positions corresponding to the A byte arrays to obtain E byte array sets; E is a positive integer greater than 1 and less than A;
[0174] The second determining subunit 1223 is used to include the byte array B in the E byte array sets. c The byte array collection is determined to be the same as the byte array B c the associated associative byte array;
[0175] The third processing unit 123 may include: an array acquiring subunit 1232 and a third processing subunit 1233 .
[0176] Array acquisition subunit 1232, used to acquire byte array B cF byte arrays in the byte array set; F is a positive integer, and F is less than A;
[0177] The third processing sub-unit 1233 is configured to perform concatenation processing on the numbers corresponding to the F byte arrays, the total number of slices A, and the F byte arrays to obtain an associated slice data structure.
[0178] Among them, the specific functional implementation methods of the second processing subunit 1222, the second determination subunit 1223, the array acquisition subunit 1232 and the third processing subunit 1233 can be found in steps S203-S204 in the corresponding embodiment of Figure 6 above, and will not be repeated here.
[0179] Please refer to FIG. 10 again, the first determining unit 122 may include: a third determining subunit 1224 .
[0180] The third determining subunit 1224 is configured to determine the A byte arrays as being equal to the byte array B if the verification range is the entire verification range. c the associated associative byte array;
[0181] The third processing unit 123 may include: a fourth processing sub-unit 1234 .
[0182] The fourth processing sub-unit 1234 is configured to perform concatenation processing on the serial numbers corresponding to the A byte arrays, the total number of slices A, and the A byte arrays to obtain an associated slice data structure.
[0183] The specific functional implementation of the third determining subunit 1224 and the fourth processing subunit 1234 can be found in steps S203 to S204 in the embodiment corresponding to FIG6 , and will not be described in detail here.
[0184] Referring again to FIG. 10 , the fragment generation module 12 may include: a fourth processing unit 126 and a second acquisition unit 127 .
[0185] The fourth processing unit 126 is configured to perform hash processing on the associated shard data structure to obtain a hash value of the associated shard data structure, and determine the hash value as a check code of the associated shard data structure; or
[0186] The second obtaining unit 127 is used to obtain the device private key of the service device, sign the associated shard data structure using the device private key, obtain the signature value of the associated shard data structure, and determine the signature value as the verification code of the associated shard data structure.
[0187] The specific functional implementation of the fourth processing unit 126 and the second obtaining unit 127 can be found in step S102 of the embodiment corresponding to FIG3 , which will not be described in detail here.
[0188] From the above, it can be seen that when the storage capacity occupied by the intermediate code corresponding to the smart contract is greater than or equal to the block storage capacity, by sending A program fragments to the blockchain node separately, the blockchain node can still assemble the complete intermediate code and then run the complete intermediate code (that is, run the intermediate code corresponding to the smart contract). Therefore, the present application has no limit on the storage capacity occupied by the intermediate code corresponding to the smart contract, which can improve the applicability of smart contract deployment; in addition, the present application can avoid pre-installing the intermediate code corresponding to the smart contract on the blockchain node, avoid manual approval of the intermediate code corresponding to the smart contract, thereby improving the installation efficiency of the smart contract and avoiding manual approval errors.
[0189] Please refer to Figure 11, which is a second structural diagram of a blockchain-based data processing device provided in an embodiment of the present application. As shown in Figure 11, the blockchain-based data processing device 2 can run on a computer device, which can be a blockchain node. The above-mentioned blockchain-based data processing device 2 can be a computer program (including program code) running on a computer device, for example, the data processing device is an application software; the data processing device can be used to execute the corresponding steps of the method provided in the embodiment of the present application. As shown in Figure 11, the blockchain-based data processing device 2 can include: a shard acquisition module 21 and an array assembly module 22.
[0190] The shard acquisition module 21 is used to obtain program shards initiated by the business device and uploaded to the chain, and obtain the total number of shards A among the uploaded program shards; A is a positive integer greater than 1; the business device is used to shard the intermediate code corresponding to the smart contract to obtain A byte arrays; each byte array corresponds to a program shard;
[0191] The array assembly module 22 is used to count the total number of program fragments that have been chained. If the total number is equal to the total number of fragments A, the byte arrays included in the A program fragments are assembled according to the numbers included in the A program fragments to obtain a complete intermediate code.
[0192] The specific functional implementation of the shard acquisition module 21 and the array assembly module 22 can be found in steps S301 to S302 in the embodiment corresponding to FIG8 , and will not be described in detail here.
[0193] Please refer to Figure 11 again. A program slice includes program slice G h , h is a positive integer, and h is less than or equal to A; the blockchain-based data processing device 2 may further include: a sharding verification module 23 and a code storage module 24.
[0194] The fragmentation verification module 23 is used to fragment G according to the program.h Included checksum, program fragment G h Perform a legality check and obtain the verification result I h ;
[0195] The code storage module 24 is used to store the complete intermediate code if the verification results corresponding to the A program slices are all verification-passing results; the A verification results that are all verification-passing results are used to indicate that the complete intermediate code is the same as the intermediate code corresponding to the smart contract.
[0196] The specific functional implementation of the fragment verification module 23 and the code storage module 24 can be found in step S302 of the embodiment corresponding to FIG8 above, and will not be described in detail here.
[0197] Referring again to FIG. 11 , the fragment verification module 23 may include: a first determination unit 231 , a first processing unit 232 , and a second determination unit 233 .
[0198] The first determining unit 231 is used to determine the verification range, and determine the program slice G in the A program slices according to the verification range. h An associated associated program slice; an associated program slice includes one or more program slices;
[0199] The first processing unit 232 is configured to perform concatenation processing on the serial number of the associated program fragment, the total number of fragments A, and the byte array of the associated program fragment to obtain a fragment data structure to be verified;
[0200] The second determining unit 233 is configured to determine the segment data structure to be checked and the program segment G h Included check code, determine the check result I h .
[0201] The specific functional implementation of the first determining unit 231 , the first processing unit 232 and the second determining unit 233 can be found in step S302 in the embodiment corresponding to FIG8 , which will not be described in detail here.
[0202] Referring again to FIG. 11 , the first determining unit 231 may include: a first determining subunit 2311 , a second determining subunit 2312 , a first acquiring subunit 2313 , and a third determining subunit 2314 .
[0203] The first determining subunit 2311 is configured to, if the verification range is the verification slice range, select program slice G from among the A program slices. h Determined to be with program shard G h associated associated program slices;
[0204] The second determining subunit 2312 is configured to determine A program slices as being consistent with program slice G if the verification range is the entire verification range. h associated associated program slices;
[0205] The first acquisition subunit 2313 is used to acquire the program fragment G if the verification range is the verification group range. h The number group carried by the included check code; the number group includes one or more numbers, and the number group includes program fragment G h The number in;
[0206] The third determining subunit 2314 is configured to determine, among the A program slices, the program slice corresponding to the number group as the program slice G. h The associated associated program slice.
[0207] Among them, the specific functional implementation of the first determining subunit 2311, the second determining subunit 2312, the first obtaining subunit 2313 and the third determining subunit 2314 can refer to step S302 in the embodiment corresponding to Figure 8 above, and will not be repeated here.
[0208] Referring again to FIG. 11 , the second determining unit 233 may include: a first processing subunit 2331 , a verification and comparison subunit 2332 , a fourth determining subunit 2333 , and a fifth determining subunit 2334 .
[0209] The first processing sub-unit 2331 is used to: h If the included check code is a hash value, hash processing is performed on the shard data structure to be checked to obtain the hash value to be checked;
[0210] Verification and comparison subunit 2332 is used to compare the hash value to be verified and the program fragment G h Compare with the included checksum;
[0211] The fourth determining subunit 2333 is used to determine whether the hash value and the program fragment G to be verified h If the check codes included are the same, the check result is determined as the check result I h ;
[0212] The fifth determining subunit 2334 is used to determine whether the hash value and the program fragment G to be verified h If the verification code included is different, the verification failure result is determined as the verification result I h .
[0213] Among them, the specific functional implementation methods of the first processing subunit 2331, the verification and comparison subunit 2332, the fourth determination subunit 2333 and the fifth determination subunit 2334 can be found in step S302 of the embodiment corresponding to Figure 8 above, and will not be repeated here.
[0214] Referring again to FIG. 11 , the second determining unit 233 may include: a second acquiring subunit 2335 , a second processing subunit 2336 , a sixth determining subunit 2337 , and a seventh determining subunit 2338 .
[0215] The second acquisition subunit 2335 is used to h If the included check code is a signature value, the device public key of the business device is obtained;
[0216] The second processing sub-unit 2336 is used to process the program segment G using the device public key. h The included verification code is used to verify the signature and obtain the verification result;
[0217] The sixth determining subunit 2337 is configured to determine the verification pass result as verification result 1 if the verification result is a successful verification result. h ;
[0218] The seventh determining subunit 2338 is configured to determine the verification failure result as the verification result I if the verification result is a verification failure result. h .
[0219] Among them, the specific functional implementation of the second acquisition subunit 2335, the second processing subunit 2336, the sixth determination subunit 2337 and the seventh determination subunit 2338 can be found in step S302 of the embodiment corresponding to Figure 8 above, and will not be repeated here.
[0220] Referring again to FIG. 11 , the fragment acquisition module 21 may include: a fragment acquisition unit 211 , a second processing unit 212 , and a third determination unit 213 .
[0221] The shard acquisition unit 211 is used to acquire program shards initiated by the business device and package the program shards into blocks to be uploaded to the blockchain;
[0222] The second processing unit 212 is used to perform consensus processing on the block to be put on the chain and obtain a consensus result. If the consensus result is a consensus-passed result, the block to be put on the chain is put on the chain;
[0223] The third determining unit 213 is configured to determine that the program slice is a program slice that has been chained if the block to be chained is successfully chained, and obtain the program slice that has been chained.
[0224] The specific functional implementation of the fragment acquisition unit 211, the second processing unit 212 and the third determination unit 213 can be found in step S301 in the embodiment corresponding to FIG8 above, and will not be described in detail here.
[0225] From the above, it can be seen that when the storage capacity occupied by the intermediate code corresponding to the smart contract is greater than or equal to the block storage capacity, by sending A program fragments to the blockchain node separately, the blockchain node can still assemble the complete intermediate code and then run the complete intermediate code (that is, run the intermediate code corresponding to the smart contract). Therefore, the present application has no limit on the storage capacity occupied by the intermediate code corresponding to the smart contract, which can improve the applicability of smart contract deployment; in addition, the present application can avoid pre-installing the intermediate code corresponding to the smart contract on the blockchain node, avoid manual approval of the intermediate code corresponding to the smart contract, thereby improving the installation efficiency of the smart contract and avoiding manual approval errors.
[0226] Please refer to Figure 12, which is a structural diagram of a computer device provided in an embodiment of the present application. As shown in Figure 12, the computer device 1000 may include: at least one processor 1001, such as a CPU, at least one network interface 1004, a user interface 1003, a memory 1005, and at least one communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. Among them, in some embodiments, the user interface 1003 may include a display screen (Display), a keyboard (Keyboard), and the network interface 1004 may optionally include a standard wired interface, a wireless interface (such as a 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 storage. The memory 1005 may optionally also be at least one storage device located away from the aforementioned processor 1001. As shown in Figure 12, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a computer program.
[0227] In the computer device 1000 shown in Figure 12, the network interface 1004 can provide network communication functions; the user interface 1003 is mainly used to provide an input interface for the user; and the processor 1001 can be used to call the computer program stored in the memory 1005, so as to execute the implementation methods provided by the various steps shown in Figure 3 or Figure 8 above. For details, please refer to the implementation methods provided by the above steps, which will not be repeated here.
[0228] It should be understood that the computer device 1000 described in the embodiments of the present application can execute the description of the data processing method or device in the above embodiments, which will not be repeated here. In addition, the description of the beneficial effects of using the same method will not be repeated.
[0229] The present application also provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the data processing methods or apparatuses described in the preceding embodiments, which are not described in detail here. Furthermore, the description of the beneficial effects of the same methods is not described in detail here.
[0230] The computer-readable storage medium may be the data processing device provided in any of the aforementioned embodiments or the internal storage unit of the computer device, such as the hard disk or 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, etc. equipped on the computer device. Furthermore, the computer-readable storage medium may also include both the internal storage unit of the computer device and an external storage 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.
[0231] The present application also provides a computer program product, comprising a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, enabling the computer device to perform the data processing methods or apparatuses described in the preceding embodiments, which are not further detailed here. Furthermore, the beneficial effects of the same methods are not further detailed here.
[0232] The terms "first", "second", etc. in the description, claims, and drawings of the embodiments of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "comprising" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product, or device comprising a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules not listed, or may optionally include other step units inherent to these processes, methods, apparatuses, products, or devices.
[0233] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0234] The above disclosure is only a preferred embodiment of the present application, and certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A data processing method based on blockchain, characterized in that: The method is performed by a service device, and the method includes: The intermediate code corresponding to the smart contract is sliced and processed to obtain A byte arrays; A is a positive integer greater than 1; Generate A program slices according to the serial number of each byte array, the total number of slices A and each byte array, wherein each byte array corresponds to one program slice; The A program slices are sent to the blockchain network so that the blockchain nodes in the blockchain network can process the A program slices on the chain; the A program slices that have been on the chain are used to be assembled to generate a complete intermediate code.
2. The method according to claim 1, characterized in that: The intermediate code corresponding to the smart contract is sliced to obtain A byte arrays, including: Encode the source code corresponding to the smart contract to obtain the intermediate code corresponding to the smart contract, and obtain the storage capacity occupied by the intermediate code corresponding to the smart contract; Obtaining the block storage capacity, and comparing the storage capacity occupied by the intermediate code corresponding to the smart contract with the block storage capacity; the block storage capacity is used to represent the storage capacity of a block in the blockchain; If the storage capacity occupied by the intermediate code corresponding to the smart contract is equal to or greater than the block storage capacity, the intermediate code corresponding to the smart contract is fragmented according to the block storage capacity to obtain A byte arrays.
3. The method according to claim 1 or 2, characterized in that: The A byte array includes the byte array B c , the byte array B c Corresponding program fragment D c , c is a positive integer and c is less than or equal to A; According to the byte array B c The number, the total number of slices A and the byte array B c , generate program fragment D c ,include: According to the byte array B c At the array position in the A byte array, generate the byte array B c The corresponding number; Determine a verification range, and determine, according to the verification range, in the A byte arrays, the byte arrays corresponding to the byte array B c an associated associated byte array; the associated byte array comprising one or more byte arrays; The serial number corresponding to the associated byte array, the total number of slices A and the associated byte array are concatenated to obtain an associated slice data structure; The check code corresponding to the associated sharding data structure is determined as the byte array B c The corresponding check code; According to the byte array B c The number of the slices, the total number of slices A, the byte array B c and the byte array B c The corresponding checksum generates program fragment D c .
4. The method according to claim 3, characterized in that The verification range is determined according to the verification range in the A byte arrays. c The associated associative byte array consists of: If the verification range is a verification fragment range, then in the A byte arrays, the byte array B c Determine as the byte array B c the associated associative byte array; Then the serial number corresponding to the associated byte array, the total number of slices A and the associated byte array are concatenated to obtain an associated slice data structure, including: For the byte array B c The corresponding number, the total number of slices A and the byte array B c Perform splicing processing to obtain the associated shard data structure.
5. The method according to claim 3, characterized in that: The verification range is determined according to the verification range in the A byte arrays. c The associated associative byte array consists of: If the verification range is a verification grouping range, the A byte arrays are grouped according to the array positions corresponding to the A byte arrays to obtain E byte array sets; E is a positive integer greater than 1, and E is less than A; The byte array B will be included in the E byte array sets. c The byte array collection is determined as the byte array B c The associated byte array B includes the byte array B c The byte array set contains F byte arrays; Then the serial number corresponding to the associated byte array, the total number of slices A and the associated byte array are concatenated to obtain an associated slice data structure, including: From the byte array B c The F byte arrays are obtained from the byte array set; F is a positive integer, and F is less than A; The serial numbers corresponding to the F byte arrays, the total number of slices A, and the F byte arrays are concatenated to obtain an associated slice data structure.
6. The method according to claim 3, characterized in that: The verification range is determined according to the verification range in the A byte arrays. c The associated associative byte array consists of: If the verification range is the entire verification range, the A byte arrays are determined to be the same as the byte array B. c the associated associative byte array; Then the serial number corresponding to the associated byte array, the total number of slices A and the associated byte array are concatenated to obtain an associated slice data structure, including: The serial numbers corresponding to the A byte arrays, the total number of slices A, and the A byte arrays are concatenated to obtain an associated slice data structure.
7. The method according to any one of claims 3 to 6, characterized in that: Also includes: Performing hash processing on the associated shard data structure to obtain a hash value of the associated shard data structure, and determining the hash value as a check code of the associated shard data structure; or Obtain a device private key of the business device, use the device private key to sign the associated shard data structure, obtain a signature value of the associated shard data structure, and determine the signature value as a verification code of the associated shard data structure.
8. A data processing method based on blockchain, characterized in that: The method is performed by a blockchain node, and the method includes: Obtain the program shards initiated by the business device and uploaded to the chain, and obtain the total number of shards A in the program shards uploaded to the chain; A is a positive integer greater than 1; the business device is used to shard the intermediate code corresponding to the smart contract to obtain A byte arrays; each of the byte arrays corresponds to one of the program shards; The total number of the chained program fragments is counted. If the total number is equal to the total number of fragments A, the byte arrays respectively included in the A program fragments are assembled according to the serial numbers respectively included in the A program fragments to obtain a complete intermediate code.
9. The method according to claim 8, characterized in that The method further comprises: According to the verification code included in each of the program slices, respectively verify the legitimacy of each of the program slices to obtain a verification result; If all A verification results are verification passing results, the complete intermediate code is stored; all A verification results are verification passing results, which is used to indicate that the complete intermediate code is the same as the intermediate code corresponding to the smart contract.
10. The method according to claim 9, characterized in that The A program slices include program slice G h , h is a positive integer, and h is less than or equal to A; according to the program segment G h The checksum included in the program segment G h Perform a legality check and obtain the verification result I h ,include: Determine a verification range, and determine, according to the verification range, a program slice G in the A program slices. h An associated associated program slice; the associated program slice comprises one or more program slices; The serial number of the associated program slice, the total number of slices A and the byte array of the associated program slice are concatenated to obtain a slice data structure to be checked; According to the to-be-checked slice data structure and the program slice G h Included check code, determine the check result I h .
11. The method according to claim 10, characterized in that The checking range is determined according to the program slice G in the A program slices. h The associated associated program slices include: If the verification range is a verification slice range, then among the A program slices, the program slice G h Determined to be related to the program slice G h associated associated program slices; If the verification range is the entire verification range, the A program slices are determined to be the same as the program slice G. h associated associated program slices; If the verification range is a verification group range, then obtain the program fragment G h The number group carried by the verification code included; the number group includes one or more numbers, and the number group includes the program segment G h and in the A program slices, the program slice corresponding to the number group is determined as the program slice G h The associated associated program slice.
12. The method according to claim 10 or 11, characterized in that: The method according to the to-be-checked slice data structure and the program slice G h Included check code, determine the check result I h ,include: If the program segment G h If the included check code is a hash value, hash processing is performed on the shard data structure to be checked to obtain the hash value to be checked; The hash value to be verified and the program fragment G h The included checksum is compared; If the hash value to be verified and the program fragment G h If the verification code included is the same, the verification result is determined as the verification result I h ; If the hash value to be verified and the program fragment G h If the verification code included is different, the verification failure result is determined as the verification result I h .
13. The method according to claim 10 or 11, characterized in that: The method according to the to-be-checked slice data structure and the program slice G h Included check code, determine the check result I h ,include: If the program segment G h If the included verification code is a signature value, the device public key of the service device is obtained; The program segment G is sharded by the device public key. h The included verification code is used for signature verification to obtain the verification result; If the verification result is a successful verification result, the verification result is determined as verification result I h ; If the verification result is a verification failure, the verification failure result is determined as verification result I h .
14. The method according to any one of claims 8 to 13, characterized in that: The obtaining of program fragments initiated by the business device and uploaded to the chain includes: Obtain the program fragment initiated by the business device, and package the program fragment into a block to be uploaded to the chain; Performing consensus processing on the block to be put on the chain to obtain a consensus result. If the consensus result is a consensus passing result, the block to be put on the chain is put on the chain; If the block to be chained is successfully chained, it is determined that the program slice is a program slice that has been chained, and the program slice that has been chained is obtained.
15. A data processing device based on blockchain, characterized in that: The device is executed on a business device and includes: The code processing module is used to slice the intermediate code corresponding to the smart contract to obtain A byte arrays; A is a positive integer greater than 1; A slice generation module, used for generating A program slices according to the serial number of each byte array, the total number of slices A and each byte array, wherein each byte array corresponds to one program slice; The shard sending module is used to send the A program shards to the blockchain network so that the blockchain nodes in the blockchain network can process the A program shards on the chain; the A program shards that have been on the chain are used to be assembled to generate a complete intermediate code.
16. A data processing device based on blockchain, characterized in that: The device runs on a blockchain node, and the device includes: The shard acquisition module is used to acquire the program shards initiated by the business device and uploaded to the chain, and acquire the total number of shards A from the program shards uploaded to the chain; A is a positive integer greater than 1; the business device is used to perform sharding on the intermediate code corresponding to the smart contract to obtain A byte arrays; each byte array corresponds to one of the program shards; The array assembly module is used to count the total number of the program fragments that have been chained. If the total number is equal to the total number of fragments A, the byte arrays respectively included in the A program fragments are assembled according to the numbers respectively included in the A program fragments to obtain a complete intermediate code.
17. A computer device, characterized in that: include: Processor, memory, and network interface; The processor is connected to the memory and the network interface, wherein the network interface is used to provide a data communication function, the memory is used to store a computer program, and the processor is used to call the computer program so that the computer device executes the blockchain-based data processing method according to any one of claims 1 to 14.
18. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which is suitable for being loaded and executed by a processor so that a computer device having the processor executes the blockchain-based data processing method according to any one of claims 1 to 14.
19. A computer program product, characterized in that The computer program product includes a computer program, which is stored in a computer-readable storage medium, and the computer program is suitable for being read and executed by a processor so that a computer device having the processor performs the blockchain-based data processing method according to any one of claims 1 to 14.
Citation Information
Patent Citations
Multi-block chain sectional processing method and device
CN106899680A
Intelligent contract deployment method and device, transaction method and device and electronic equipment
CN114168159A
Service code execution method and device, electronic equipment and storage medium
CN114840268A
Deployment of smart contract
WO2021208956A1
Smart contract deployment method and apparatus, smart contract transaction method and apparatus, and electronic device
WO2023109270A1