Data processing method and device based on block chain and readable storage medium
By sharding the intermediate code of the smart contract and uploading it to the blockchain network, it solves the problems of limited applicability of smart contract deployment and low installation efficiency, and achieves more efficient smart contract deployment and installation.
Patent Information
- Application Number
- CN202310898387.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-20
- Publication Date
- 2025-01-21
AI Technical Summary
The applicability of smart contract deployment in the prior art is limited by the block size, and the packages for pre-installing smart contracts offline are inefficient and are prone to manual approval errors.
By sharding the intermediate code of the smart contract, multiple program shards are generated and processed on the blockchain network. The blockchain nodes are assembled to generate complete intermediate code.
It improves the applicability of smart contract deployment, improves the installation efficiency of smart contracts, and avoids manual approval errors.
Smart Images

Figure CN119336341A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a data processing method, device, and readable storage medium based on blockchain. Background Art
[0002] A smart contract is an automated program based on blockchain technology that can execute transactions and agreements without an intermediary. It has the characteristics of decentralization, transparency, security, and programmability.
[0003] Smart contracts need to be deployed on blockchain nodes. Existing technologies include the following two deployment methods. The first method is that the blockchain node packages the smart contract into a block, reaches a consensus on the block through a consensus mechanism, and then successfully deploys the smart contract. However, in order to ensure the security of the blockchain, it is necessary to reach a consensus on the block as soon as possible. Therefore, the blockchain imposes a size limit on the block, and then limits the size of the smart contract. Therefore, the first method reduces the applicability of smart contract deployment. The second method is to package the source code of the smart contract, generate an installable package, and install the package on each blockchain node. The administrator of the blockchain node manually verifies the legitimacy of the package. However, pre-installing the smart contract package offline will not only reduce the installation efficiency of the smart contract, but may also result in manual approval errors. Summary of the invention
[0004] 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.
[0005] 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:
[0006] The intermediate code corresponding to the smart contract is sliced to obtain A byte arrays; A is a positive integer greater than 1; the A byte arrays include byte array B c , c is a positive integer and c is less than or equal to A;
[0007] According to the byte array B c The number, the total number of fragments A and the byte array B c , generate program fragment D c ;
[0008] The program slices corresponding to the A byte arrays 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 on the chain are used to be assembled to generate a complete intermediate code.
[0009] 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:
[0010] 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; one byte array is used by the business device to generate one program shard;
[0011] 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, assemble the byte arrays included in the A program fragments according to the serial numbers included in the A program fragments to obtain the complete intermediate code.
[0012] On the one hand, an embodiment of the present application provides a data processing device based on blockchain, which runs on a business device and includes:
[0013] 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 byte arrays include byte array B c , c is a positive integer and c is less than or equal to A;
[0014] The fragment generation module is used to generate a fragment according to the byte array B c The number, the total number of fragments A and the byte array B c , generate program fragment D c ;
[0015] The shard sending module is used to send the program shards corresponding to the A byte arrays 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.
[0016] Among them, the code processing module includes:
[0017] A first processing unit is used to encode the source code corresponding to the smart contract, obtain the intermediate code corresponding to the smart contract, and obtain the storage capacity occupied by the intermediate code corresponding to the smart contract;
[0018] A first acquisition unit is used to acquire the block storage capacity and compare 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;
[0019] The second processing unit is used 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.
[0020] The shard generation module includes:
[0021] The first generating unit is used to generate a byte array B according to the c Generate byte array B at array position in byte array A c The corresponding number;
[0022] The first determining unit is used to determine the verification range, and according to the verification range, determine the byte arrays A and B in the byte array. c an associated associative byte array; an associative byte array comprises one or more byte arrays;
[0023] A third processing unit is used to perform concatenation processing on 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;
[0024] The second determining unit is used to determine the check code corresponding to the associated fragment data structure as a byte array B c The corresponding check code;
[0025] The second generation unit is used to generate a byte array B according to the c Number, total number of slices A, byte array B c and the byte array B c The corresponding check code generates program fragment D c .
[0026] Wherein, the first determining unit includes:
[0027] The first determination subunit is used to, if the verification range is the verification fragment range, convert byte array B into A byte arrays. c Determine the byte array B c the associated associative byte array;
[0028] The third processing unit includes:
[0029] The first processing subunit is used to process the byte array B c The corresponding number, total number of slices A and byte array B c Perform splicing processing to obtain the associated shard data structure.
[0030] Wherein, the first determining unit includes:
[0031] The second processing subunit is used for grouping the A byte arrays according to the array positions corresponding to the A byte arrays to obtain E byte array sets if the verification range is a verification group range; E is a positive integer greater than 1, and E is less than A;
[0032] The second determining subunit is used to include the byte array B in the E byte array sets. c The byte array collection is determined as the byte array B c the associated associative byte array;
[0033] The third processing unit includes:
[0034] The array acquisition subunit is used to acquire the byte array B c F byte arrays in the byte array set; F is a positive integer, and F is less than A;
[0035] The third processing sub-unit is used to perform concatenation processing on the serial 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.
[0036] Wherein, the first determination unit includes:
[0037] The third determining subunit is used to determine the A byte arrays as being consistent with the byte array B if the verification range is the verification range of the entire range. c the associated associative byte array;
[0038] The third processing unit includes:
[0039] The fourth processing sub-unit is used 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.
[0040] The shard generation module includes:
[0041] A fourth processing unit 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
[0042] The second acquisition unit is used to obtain a device private key of the business device, and use the device private key to sign the associated shard data structure to 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.
[0043] On the one hand, an embodiment of the present application provides a data processing device based on blockchain, which runs on a blockchain node and includes:
[0044] The shard acquisition module is used to 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; one byte array is used by the business device to generate one program shard;
[0045] The array assembly module 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 the complete intermediate code.
[0046] Among them, A program slices include program slice G h , h is a positive integer, and h is less than or equal to A;
[0047] The data processing device further comprises:
[0048] The sharding verification module is used to shard G according to the program h Included checksum, program segment G h Perform a legality check and obtain the verification result I h ;
[0049] The code storage module 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.
[0050] The fragmentation verification module includes:
[0051] The first determining unit is used to determine a verification range, and determine the program slice G in the A program slices according to the verification range. h An associated associated program slice; the associated program slice includes one or more program slices;
[0052] A first processing unit is used to perform splicing processing on the serial number of the associated program slice, the total number of slices A, and the byte array included in the associated program slice to obtain a slice data structure to be checked;
[0053] The second determining unit is used to determine the slice data structure to be checked and the program slice G h Included check code, determine the check result I h .
[0054] Wherein, the first determination unit includes:
[0055] The first determining subunit is configured to, if the verification range is the verification slice range, select program slice G from among the A program slices. hDetermined to be with program slice G h associated associated program slices;
[0056] The second determining subunit is configured to determine A program slices as being consistent with program slice G if the verification range is the verification range of the entire program slice. h associated associated program slices;
[0057] The first acquisition subunit 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 segment G h The number in;
[0058] The third determining subunit is used to determine the program slice corresponding to the number group as the same as the program slice G among the A program slices. h The associated associated program slice.
[0059] Wherein, the second determining unit includes:
[0060] The first processing subunit is used for the program segment G h If the included check code is a hash value, the shard data structure to be checked is hashed to obtain the hash value to be checked;
[0061] The verification comparison subunit is used to compare the hash value to be verified and the program fragment G h The included checksum is compared;
[0062] The fourth determination subunit is used to determine whether the hash value to be verified and the program segment G h If the verification code included is the same, the verification result is determined as the verification result I h ;
[0063] The fifth determination subunit is used to determine whether the hash value to be verified and the program segment G h If the verification code included is different, the verification failure result is determined as the verification result I h .
[0064] Wherein, the second determining unit includes:
[0065] The second acquisition subunit is used for the program segment G h If the included verification code is a signature value, the device public key of the business device is obtained;
[0066] The second processing subunit is used to process the program segment G through the device public key. h The included verification code is used for signature verification to obtain the verification result;
[0067] The sixth determination subunit is used to determine the verification result as the verification result I if the verification result is a successful verification result. h ;
[0068] The seventh determination subunit is used to determine the verification failure result as the verification result I if the verification result is a verification failure result. h .
[0069] The shard acquisition module includes:
[0070] A shard acquisition unit, used to acquire program shards initiated by the business device, and pack the program shards into a block to be uploaded to the chain;
[0071] The second processing unit 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 passing result, the block to be put on the chain is put on the chain;
[0072] The third determining unit is used to determine that the program shard is a program shard that has been chained if the block to be chained is successfully chained, and obtain the program shard that has been chained.
[0073] On one hand, the present application provides a computer device, including: a processor, a memory, and a network interface;
[0074] 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 method in the embodiment of the present application.
[0075] On 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 method in the embodiment of the present application.
[0076] 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 executes the method in the embodiment of the present application.
[0077] In the 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; A byte arrays include byte array B c , further, the service device may generate a byte array B c The number, the total number of fragments A and the byte array B cProgram fragment D c ; Further, the program slices corresponding to the A byte arrays 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. As can be seen from the above, when the storage capacity occupied by the intermediate code corresponding to the smart contract is greater than or equal to the block storage capacity of a block, by sending the A program slices to the blockchain node respectively, the blockchain node can still assemble the complete intermediate code, and then run the complete intermediate code, that is, the intermediate code corresponding to the smart contract, so the application is adopted, and there is no limit on the storage capacity occupied by the intermediate code corresponding to the smart contract, so the applicability of the deployment of the smart contract can be improved; in addition, the application can avoid pre-installing the intermediate code corresponding to the smart contract on the blockchain node, so it can avoid manual approval of the intermediate code corresponding to the smart contract, thereby improving the installation efficiency of the smart contract, and can avoid manual approval errors. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0079] Figure 1 It is a schematic diagram of a system architecture provided by an embodiment of the present application;
[0080] Figure 2 This is a schematic diagram of a data processing scenario based on blockchain provided by an embodiment of the present application. Figure 1 ;
[0081] Figure 3 This is a flowchart of a data processing method based on blockchain provided in an embodiment of the present application. Figure 1 ;
[0082] Figure 4 This is a schematic diagram of a data processing scenario based on blockchain provided by an embodiment of the present application. Figure 2 ;
[0083] Figure 5 This is an interactive schematic diagram of a blockchain-based data processing method provided in an embodiment of the present application;
[0084] Figure 6 This is a flowchart of a data processing method based on blockchain provided in an embodiment of the present application. Figure 2 ;
[0085] Figure 7This is a schematic diagram of a data processing scenario based on blockchain provided by an embodiment of the present application. Figure 3 ;
[0086] Figure 8 This is a flowchart of a data processing method based on blockchain provided in an embodiment of the present application. Figure 3 ;
[0087] Fig. 9 This is a flowchart of a data processing method based on blockchain provided in an embodiment of the present application. Figure 4 ;
[0088] Fig.10 This is a schematic diagram of a data processing device based on blockchain provided in an embodiment of the present application. Figure 1 ;
[0089] Fig.11 This is a schematic diagram of a data processing device based on blockchain provided in an embodiment of the present application. Figure 2 ;
[0090] Fig.12 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0091] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0092] To facilitate understanding, some nouns are briefly explained as follows:
[0093] 1. Blockchain: In a narrow sense, blockchain is a chain data structure with blocks as the basic unit. The digital summary is used in the block to verify the transaction history previously obtained, which is suitable for the needs of tamper-proof and scalability in the distributed accounting scenario; in a broad sense, blockchain also refers to the distributed accounting technology implemented by the blockchain structure, including distributed consensus, privacy and security protection, peer-to-peer communication technology, network protocols, smart contracts, etc. The goal of the blockchain is to realize a distributed data record book, which only allows additions but not deletions. The basic structure of the underlying ledger is a linear linked list. The linked list is composed of "blocks" connected in series, and the hash value of the previous block is recorded in the subsequent block. Whether each block (and the transactions in the block) is legal can be quickly verified by calculating the hash value. If a node in the network proposes to add a new block, it must reach a consensus on the block through the consensus mechanism.
[0094] 2. Blockchain nodes: The blockchain network divides nodes into consensus nodes (also called core nodes) and synchronization nodes (which can include data nodes and light nodes). Among them, the consensus node is responsible for the consensus business of the entire blockchain network; the synchronization node is responsible for synchronizing the ledger information of the consensus node, that is, synchronizing the latest block data. Whether it is a consensus node or a synchronization node, its internal structure includes network communication components, because the blockchain network is essentially a peer-to-peer network, and it needs to communicate with other nodes in the blockchain network through peer-to-peer components. The resources and services in the blockchain network are scattered on various nodes, and the transmission of information and the implementation of services are directly carried out between nodes without the intervention of intermediate links or centralized servers (third parties).
[0095] 3. Block: It is a data packet that carries transaction data on the blockchain network. It is a data structure marked with a timestamp and the hash value corresponding to the previous block. The block is verified and confirmed by the consensus mechanism of the network. The block includes a block header and a block body. The block header can record the meta information of the current block, including the current version number, the hash value corresponding to the previous block, the timestamp, the random number, the hash value of the MerkleRoot, and other data. The block body can record the detailed data generated within a period of time, including all transaction records or other information generated during the block creation process that have been verified by the current block, which can be understood as a form of account book. In addition, the detailed data of the block body can include the unique Merkle Root generated through the hash process of the Merkle Tree and recorded in the block header.
[0096] 4. Hash value: Also known as information characteristic value or characteristic value, the hash value is generated by converting input data of any length into a password and performing a fixed output through a hash algorithm. The original input data cannot be retrieved by decrypting the hash value. It is a one-way encryption function. In the blockchain, each block (except the initial block) contains the hash value of the previous block. The hash value is the potential core foundation and the most important aspect of blockchain technology. It retains the authenticity of the recorded and viewed data, as well as the integrity of the blockchain as a whole.
[0097] 5. Public key and private key: Public key and private key are a key pair obtained through an algorithm. The public key is the public part of the key pair, and the private key is the non-public part. The public key is usually used to encrypt data, verify digital signatures, etc. This algorithm can ensure that the key pair obtained is unique. When using this key pair, if one of the keys is used to encrypt a piece of data, the other key must be used to decrypt it. For example, if the data is encrypted with the public key, it must be decrypted with the private key. If it is encrypted with the private key, it must also be decrypted with the public key, otherwise the decryption will not be successful.
[0098] 6. Asymmetric signature: The signature algorithm includes two keys, a public key (public key for short) and a private key (private key for short). The public key and the private key are a pair. If the private key is used to sign data, the signature can only be verified with the corresponding public key. Because the signing process and the verification process use two different keys, this algorithm is called an asymmetric signature. The basic process of asymmetric signature to achieve confidential information exchange can be: Party A generates a pair of keys and makes the public key public. When Party A needs to send a message to another role (Party B), it uses its own private key to sign the confidential message and then sends it to Party B; Party B then uses Party A's public key to verify the signed message.
[0099] 7. Smart Contract: A computer protocol designed to disseminate, verify or execute contracts in an information-based manner. In a blockchain system, a smart contract (contract for short) is a code that can be understood and executed by each node of the blockchain, which can execute any logic and obtain results. In actual applications, smart contracts are managed and tried 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 an operating system that provides an operating environment. A blockchain can contain multiple contracts, distinguished by a contract account (Identity, ID), identification number or name.
[0100] See also Figure 1 , Figure 1 Schematic diagram of a system architecture provided by an embodiment of the present application. Figure 1 As shown, the system architecture may include a business server 101, a terminal device cluster, and a blockchain network.
[0101] 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. Figure 1As shown, the blockchain node cluster 10 may include blockchain nodes 10a, blockchain nodes 10b, blockchain nodes 10c and blockchain nodes 10d. It is understandable that each blockchain node can receive data to be chained (such as program shards to be chained 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) when performing normal operation, and generate blocks based on the received data to be chained, and then process the blocks on the chain. It is understandable that in the specific implementation of the present application, it involves user information (such as the intermediate code and program shards corresponding to the smart contract) and other related data. 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 relevant laws, regulations and standards of relevant countries and regions.
[0102] In order to ensure data intercommunication between various blockchain nodes, there may be a data connection between each blockchain node, for example, there is a data connection between blockchain node 10a and blockchain node 10c, there is a data connection between blockchain node 10a and blockchain node 10d, there is a data connection between blockchain node 10b and blockchain node 10c, and so on. It is understandable that data or blocks can be transmitted between blockchain nodes through the above data connection. The data connection between the above blockchain nodes can be based on node identification. For each blockchain node in the blockchain network, there is a node identification corresponding to it, and each of the above blockchain nodes can store the node identification of other blockchain nodes that are connected to itself, so that the acquired data or generated blocks can be broadcast to other blockchain nodes according to the node identification of other blockchain nodes. For example, blockchain node 10a can maintain a node identification list, which stores the node names and node identifications of other blockchain nodes, as shown in Table 1.
[0103] Table 1
[0104] Node Name Node ID Blockchain Node 10b AAAAA Blockchain Node 10c BBBBB … … Blockchain Node 10d CCCCC
[0105] Among them, the node identifier can be the 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 explanation.
[0106] 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 a 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, and the same is true for data transmission between other nodes, so they will not be elaborated one by one.
[0107] It is understandable that the above-mentioned data connection does not limit the connection method, and can be directly or indirectly connected through wired communication, directly or indirectly connected through wireless communication, or through other connection methods, which are not limited in this application.
[0108] Among them, it is understandable that Figure 1 The blockchain nodes 10a, 10b, 10c, and 10d shown may 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 may 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 may 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 transfer records in the payment scenario, etc. The specific contents of the business data information in the corresponding business scenarios will not be listed one by one here.
[0109] It is understandable that the terminal device cluster may include one or more terminal devices, and the embodiment of the present application does not limit the number of terminal devices in the terminal device cluster. Figure 1As shown, the terminal device cluster may include terminal device 100a, terminal device 100b, terminal device 100c, ..., terminal device 100d. Among them, there may be a network connection between the terminal device clusters, for example, there is a network connection 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, there is a network connection 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, there is a network connection between terminal device 100b and blockchain node 10c in the blockchain network. Among them, the above-mentioned network connection does not limit the connection method, and can be directly or indirectly connected through a wired network, or directly or indirectly connected through a wireless network, or through other methods, and this application is not limited here.
[0110] It should be understood that Figure 1 Each terminal device in the terminal device cluster shown in FIG. 1 may be installed with an application client. When the application client runs in each terminal device, it may be respectively connected to the above-mentioned Figure 1 The business servers 101 shown in the figure can exchange data with each other, that is, the above-mentioned network connection; Figure 1 The blockchain network shown in the figure interacts with data. The application client can be a video application, a digital resource application, an office software application, a navigation application, a shopping application, a financial management application, a business application, a browser, and other application clients with the function of obtaining source code corresponding to the smart contract. 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.
[0111] Taking the digital resource application as an example, the business server 101 may be a collection of multiple servers including a background server corresponding to the digital resource application, a data processing server, etc. 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, and then the business server 101 can send the blockchain address creation request to other terminal devices or transmit it to the blockchain network.
[0112] The service server 101 may be a background server corresponding to the application client installed in the terminal device in the terminal device cluster. It is understandable that the system may include one or more service servers, and the number of service servers is not limited here. Figure 1The business server 101 shown can be connected to the blockchain network so as to facilitate data interaction through the network connection with the blockchain network.
[0113] The service equipment in the embodiment of the present application may include Figure 1 Any terminal device in the terminal device cluster shown and the service server 101. To facilitate subsequent understanding and description, the embodiment of the present application can be Figure 1 A device is selected from the terminal device cluster or business server 101 as a business device, for example, terminal device 100c is used as a business device. When a code slicing instruction for the intermediate code corresponding to the smart contract is obtained, the business device (such as terminal device 100c) can slice 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.
[0114] 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 is.
[0115] Further, the service device generates a byte array B c Number, total number of slices A, byte array B c and the byte array B c Corresponding checksum program fragment D c In the embodiment of the present application, program segment D c The 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, that is, A program slices, where program slice D c It can represent any one of the A program slices. This embodiment of the application does not describe the generation process corresponding to the number and the verification code, please refer to the following Figure 3 as well as Figure 6 The descriptions in the respective corresponding embodiments.
[0116] Furthermore, 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 cCarry out chain processing; In the embodiment of the present application, the blockchain node first stores the program slices that have passed the consensus (i.e., chaining), and then when the total number of program slices that have been chained is A, the byte arrays included in the A program slices are assembled through 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, so 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; when it is determined that the A program slices are all legitimate, the blockchain node stores the complete intermediate code; it can be understood that the A program slices with legitimacy can indicate that the complete intermediate code is the same as the intermediate code corresponding to the smart contract.
[0117] From the above, it can be seen that the embodiments of the present application can shard smart contract programs that are more complex to deploy and occupy a larger space, so the versatility of smart contract deployment, that is, applicability, can be improved. In addition, the embodiments of the present application send the program shards to the blockchain nodes in the manner that the blockchain will use, which can avoid pre-installing smart contracts in the blockchain nodes offline, so it can avoid manual verification of smart contracts installed on the blockchain nodes, thereby improving the installation efficiency of smart contracts and avoiding errors caused by manual verification.
[0118] The method provided in the embodiment of the present application can be executed by a computer device, which includes but is not limited to a terminal device or a business server. The business server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud database, cloud service, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN, and big data and artificial intelligence platform. Terminal devices include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc.
[0119] For further information, see Figure 2 , Figure 2 This is a schematic diagram of a data processing scenario based on blockchain provided by an embodiment of the present application. Figure 1 The implementation process of the data processing scenario can be carried out in the business server, in the terminal device, in the blockchain node, or interactively in the terminal device, the business server and the blockchain node, which is not limited here. Figure 1 For any terminal device in the terminal device cluster of the corresponding embodiment, the service server may be the above-mentioned Figure 1 The business server 101 of the corresponding embodiment, the blockchain node can be the above Figure 1 Any blockchain node in the blockchain node cluster of the corresponding embodiment. Figure 2 The present invention is described by taking a terminal device as an example. The present invention can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, etc.
[0120] like Figure 2 As shown, the terminal device 20a can slice and process 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 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 comprehensibility and the degree of ease of generating the target code are between the source language (ie, source code) and the target language (ie, target code).
[0121] For ease of understanding and description, Figure 2 For example, A is 3. Figure 2 As shown, the service device 20a generates three byte arrays, namely, the byte array 201e, the byte array 202e and the byte array 203e. The three byte arrays are all binary arrays, for example, the byte array 201e includes 00...01...11, the byte array 202e includes 00...11...11, and the byte array 203e 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), and 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.
[0122] It is understandable that the service device 20a is Figure 2 The processing of the three byte arrays in the example is the same, so the following description is based on the processing of the byte array 203e by the service device 20a as an example. The processing of the remaining two byte arrays can be referred to the description below, and will not be repeated one by one. Figure 2 As shown, the business device 20a generates a number for the byte array 203e, wherein the number is unique and sequential. The embodiment of the present application does not limit the expression method of the number and can be set according to the actual application scenario. Figure 2 3 is used as an example to illustrate the numbering of the byte array 203e. Further, the service device 20a generates a check code 201d corresponding to the byte array 203e. The present embodiment of the application does not describe the generation process of the check code for the time being. Please refer to the following Figure 3 as well as Figure 6The verification code 201d is a string of hash values. Figure 2 Take 3m...65..fe as an example.
[0123] Further, the service device 20a generates a number ( Figure 2 Taking 3 as an example), the total number of shards A( Figure 2 Taking 3 as an example), the program fragment of the byte array 203e and the check code 201d corresponding to the byte array 203e, Figure 2 Take program shard 3 as an example; wherein, the storage capacity occupied by program shard 3 is smaller than the block storage capacity in the blockchain; using the above process, business device 20a can generate program shard 1 corresponding to byte array 201e and program shard 2 corresponding to byte array 202e, and the storage capacity occupied by program shard 1 and program shard 2 respectively is smaller than the block storage capacity.
[0124] Please see again Figure 2 , business device 20a generates blockchain transaction 3 including program shard 3, and sends blockchain transaction 3 to the blockchain network. Blockchain node 20e in the blockchain network obtains blockchain transaction 3 sent by business device 20a, namely program shard 3. Further, blockchain node 20e performs on-chain processing on program shard 3. Similarly, business device 20a will also send program shard 1 and program shard 2 to the blockchain network respectively, and blockchain nodes in the blockchain network (including blockchain node 20e) will also perform on-chain processing on program shard 1 and program shard 2 respectively. Specifically, Figure 2 As shown, blockchain node 20e belongs to blockchain 201f, and blockchain node 20e packages blockchain transaction 3 into block 20g to be chained. Blockchain node 20e broadcasts block 20g to be chained to other blockchain nodes, so other blockchain nodes can also perform consensus processing on block 20g to be chained and generate consensus results. If the consensus result of the blockchain network for block 20g to be chained is a consensus passing result, blockchain node 20e can store block 20g to be chained, that is, add it to blockchain 201f, and obtain blockchain 202f.
[0125] Subsequently, the blockchain node 20g determines the number of program shards that have been chained. When the total number of program shards that have been chained is A (i.e., 3), the blockchain node 20e can assemble the byte arrays included in the three program shards through the numbers included in the three program shards to obtain the complete intermediate code. Further, through the check code 201d included in program shard 3, the blockchain node 20e can perform a legitimacy check on program shard 3 to determine the legitimacy of program shard 3; similarly, through the check code included in program shard 1, the blockchain node 20e can perform a legitimacy check on program shard 1 to determine the legitimacy of program shard 1; through the check code included in program shard 2, the blockchain node 20e can perform a legitimacy check on program shard 2 to determine the legitimacy of program shard 2. If all three program shards are legitimate, the blockchain node stores the complete intermediate code. It can be understood that the three legitimate program shards are used to indicate that the complete intermediate code is the same as the intermediate code 20b corresponding to the smart contract.
[0126] 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, the intermediate code corresponding to the smart contract. Therefore, by adopting the present application, there is no limit on the storage capacity occupied by the intermediate code corresponding to the smart contract, so the applicability of the smart contract deployment can be improved; in addition, the present application can avoid pre-installing the intermediate code corresponding to the smart contract on the blockchain node, so it 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.
[0127] For further information, see Figure 3 , Figure 3 This is a flowchart of a data processing method based on blockchain provided in an embodiment of the present application. Figure 1 The embodiments of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, etc. The data processing method can be executed by a business device, which can be the above-mentioned Figure 1 The service server 101 in the system architecture, or any terminal device in the terminal device cluster, or the service server 101 and the terminal device. Figure 3 As shown, the data processing method may at least include the following steps S101 to S103.
[0128] Step S101, the intermediate code corresponding to the smart contract is sliced 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.
[0129] 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 characterize 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.
[0130] In order to realize business functions, such as resource transfer, resource query and resource destruction, the device object (such as developers) can input or obtain the source code corresponding to the smart contract on the business device through various languages. The source code (also known as the source program) refers to an uncompiled text file written in accordance with certain programming language specifications, which is a series of human-readable computer language instructions. In order to translate the human-readable text (i.e. source code) into binary instructions that can be executed 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.
[0131] The embodiments of the present application do not limit the use of smart contracts and can be set according to the actual application scenario. Therefore, the language and content of the source code are not limited, and the encoding method and the content of the intermediate code are not limited. Among them, the encoding method includes but is not limited to compilation, packaging, etc. Compilation can turn high-level languages into binary languages that computers can recognize. Computers only recognize 1 and 0, and the compiler converts the language that people are familiar with into binary.
[0132] This solution is suitable for the scenario of deploying larger smart contracts in the blockchain system. It can be implemented through hardware, software, or a combination of hardware and software. The specific implementation process is as follows. The business device obtains the storage capacity occupied by the intermediate code corresponding to the smart contract, that is, the space occupied by the intermediate code corresponding to the smart contract; further, the block storage capacity is obtained. The block storage capacity refers to the storage capacity of a block in the blockchain, that is, the storage space. It can be understood that in order to ensure the security of the blockchain, it is necessary for the block to reach a consensus as soon as possible, so the size of the block (that is, the storage capacity) is restricted. For example, the size of a block is 1 megabyte (MB), which in turn limits the size of the smart contract. 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 for short), 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, so it will not be repeated here.
[0133] 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. At this time, the storage capacity occupied by the intermediate code corresponding to the smart contract is equal to the block storage capacity. Since the block needs to record the parent block hash value and the hash value of the current block in addition to the detailed blockchain transaction in the block body, 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 equipment can shard the intermediate code corresponding to the smart contract to obtain A byte arrays. It can be understood that the above sharding process is performed in byte order. Please refer to Figure 4 , Figure 4 This is a schematic diagram of a data processing scenario based on blockchain provided by an embodiment of the present application. Figure 2 .like Figure 4As shown, the intermediate code 30a corresponding to the smart contract can be 00...01...1100...11...1110...01...11. The business device slices the intermediate code 30a in sequence to obtain 3 (i.e., example A is 3) byte arrays. The first byte array is byte array 301b, including 00...01...11, the second byte array is byte array 302b, including 00...11...11, and the third byte array is byte array 303b, including 10...01...11.
[0134] Step S102, according to the byte array B c The number, the total number of fragments A and the byte array B c , generate program fragment D c .
[0135] 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, and determine the corresponding byte array B in byte array A according to the verification range. c The associated byte array includes 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 slice data structure is determined as the byte array B c The corresponding check code; according to the byte array B c Number, total number of slices A, byte array B c and the byte array B c The corresponding check code generates program fragment D c .
[0136] Among them, according to the verification range, determine the byte array A that matches the byte array B c The specific process of associating the associated byte arrays may include: if the verification range is the verification fragment range, then in the A byte arrays, the byte array B c Determine the byte array B c The associated byte array is associated; the number corresponding to the associated byte array, the total number of slices A and the associated byte array are concatenated to obtain the associated slice data structure. The specific process may include: c The corresponding number, total number of slices A and byte array B c Perform splicing processing to obtain the associated shard data structure.
[0137] 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 a verification code of the associated shard data structure; or a device private key of a 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 a verification code of the associated shard data structure.
[0138] According to the array position of each byte array in the A byte arrays, the business device can generate a number corresponding to each byte array. 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, and byte array 303b is the third byte array, so its number 303c can be 3. It can be understood that, Figure 4 For example, A=3, that is, the total number of slices 30d is 3.
[0139] The present application can provide three kinds of verification ranges, namely, verification shard range, verification group range and verification overall range. Among them, the verification shard range means that when the blockchain node verifies the legitimacy of A program shards, it verifies the program shards one by one. The verification group range means that when verifying the legitimacy of A program shards, the blockchain node verifies multiple groups of program shards separately. Usually, each group of program shards includes multiple program shards, and the program shards within the group are sorted according to the array position, and the groups are also sorted according to the array position. The overall verification range means that when verifying the legitimacy of A program shards, the blockchain node verifies all program shards (i.e., A program shards) together.
[0140] This application embodiment first describes the transaction sharding range, please refer to Figure 4 If the verification range is the verification fragment range, the service 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 in the three byte arrays. Further, the service device determines number 301c (such as Figure 4 Example 1), the total number of shards A (such as Figure 4 3) of the example and byte array 301b are spliced to obtain the associated fragmentation data structure corresponding to byte array 301b. Similarly, the service device performs splicing on the number 302c (such as Figure 4Example 2), the total number of slices A and the byte array 302b are spliced to obtain the associated slice data structure corresponding to the byte array 302b; the business device numbers 303c (such as Figure 4 3) of the example, the total number of fragments A and the byte array 303b are concatenated to obtain an associated fragment data structure 30e corresponding to the byte array 303b. Figure 4 An example is 3310...01...11.
[0141] 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 arrays, and based on the overall verification range, the business device determines in the A byte arrays the byte arrays associated with the byte array B c The process of associating the byte array is not described in this application embodiment, please refer to the following Figure 6 Description of the corresponding embodiment.
[0142] Furthermore, the service device determines the verification codes corresponding to the A associated shard data structures. The present application embodiment does not limit the method for determining the verification code, and any verification function is acceptable. For example, the service device may 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 verification code of the associated shard data structure. Figure 4 As shown, the service device performs hash processing on the associated shard data structure 30e to obtain a hash value 30f, that is, Figure 4 3m...65..fe in. Similarly, the service 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.
[0143] Optionally, the business device obtains a device private key, and uses the device private key to sign the associated shard data structure to obtain a signature value of the associated shard data structure, and determines the signature value as a verification code of the associated shard data structure.
[0144] Further, if Figure 4As shown, the business device generates a program fragment 3 including 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 including 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 generate a program fragment 2 including 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.
[0145] Combining step S101 and step S102, it can be known that for smart contract programs (i.e., intermediate codes) that occupy a large space, the embodiment of the present application can divide the intermediate code 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 program fragment byte array 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.
[0146] 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, which is related to the transaction size limit and block size limit of the blockchain system. The program shard needs to ensure that the storage space occupied is less than the above limit.
[0147] From the above, it can be seen that the embodiment of the present application provides a smart contract sharding deployment solution. Through this technical solution, more complex smart contracts that occupy more storage space can be deployed without changing the block size limit.
[0148] Step S103, 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.
[0149] Specifically, in the form of blockchain transactions, the business device sends the program shards corresponding to A byte arrays 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.
[0150] A feasible implementation method is as follows: in order to reduce the storage space occupied, the business device can compress A program shards separately to obtain A program shard compressed packages; further, the A program shard compressed packages are sent to the blockchain network separately in the form of blockchain transactions. Similarly, one program shard compressed package corresponds to one blockchain transaction. In this scenario, if the A program shard compressed packages are all successfully uploaded to the chain, and the blockchain node obtains the A program shard compressed packages, the A program shard compressed packages can be decompressed separately to obtain A program shards. The subsequent processing process is the same as the above description, so it will not be repeated.
[0151] Please refer to the above process Figure 5 , Figure 5 Schematic diagram of an interactive method for data processing based on blockchain provided in an embodiment of the present application. Figure 5 As shown, the method includes the following steps.
[0152] Step A: The business device encodes the smart contract program to obtain the intermediate code corresponding to the smart contract.
[0153] Specifically, the encoding method includes but is not limited to compilation or packaging, or compilation and packaging. The smart contract program refers to the source code corresponding to the smart contract.
[0154] Step B: The business device shards the intermediate code corresponding to the smart contract to form multiple program shards.
[0155] 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.
[0156] Step C: The business device sends multiple program shards to the blockchain node through blockchain transactions.
[0157] 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.
[0158] Step D: The blockchain node assembles multiple program fragments to generate complete intermediate code.
[0159] 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.
[0160] Step E: perform integrity checks on multiple program slices respectively.
[0161] 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.
[0162] Step F: When multiple program segments pass verification, the complete intermediate code is stored.
[0163] 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.
[0164] 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, the intermediate code corresponding to the smart contract. Therefore, by adopting the present application, there is no limit on the storage capacity occupied by the intermediate code corresponding to the smart contract, so the applicability of the smart contract deployment can be improved; in addition, the present application can avoid pre-installing the intermediate code corresponding to the smart contract on the blockchain node, so it 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.
[0165] For further information, see Figure 6 , Figure 6 This is a flow diagram of a data processing method provided in an embodiment of the present application. Figure 2 The method may be performed by a business server (eg, Figure 1 The service server 101 shown in the figure may also be executed by a terminal device (for example, the above Figure 1 The terminal device 100a shown in the figure can also be executed by a blockchain node (for example, the above Figure 1 The example blockchain node 10a) can also be 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 takes the method executed by the business device (specifically the business server or terminal device or the business server and terminal device) as an example for explanation. Figure 6 As shown, the method may at least include the following steps S201-S207.
[0166] Step S201, the intermediate code corresponding to the smart contract is sliced 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.
[0167] Step S202, according to the byte array B c Generate byte array B at array position in byte array A c The corresponding number.
[0168] For the specific implementation process of step S201-step S202, please refer to the above Figure 3 The description of step S101 - step S102 in the corresponding embodiment is not repeated here.
[0169] Step S203, determine the verification range, and determine the byte array A that matches the byte array B according to the verification range. c An associated associative byte array; an associative byte array consists of one or more byte arrays.
[0170] Specifically, if the verification range is the 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; in the E byte array sets, byte array B is included. c The byte array collection is determined as the byte array B c The associated associative byte array.
[0171] Specifically, if the verification range is the entire verification range, then the A byte array is determined to be the same as the byte array B c The associated associative byte array.
[0172] Above Figure 3 The corresponding embodiment describes the scenario where the verification range is the verification fragment range. This step describes the verification group range and the verification overall range. Please refer to Figure 7 , Figure 7 This is a schematic diagram of a data processing scenario based on blockchain provided by an embodiment of the present application. Figure 3 .like Figure 7 As shown, in this step example, A is equal to 4, that is, the service device generates 4 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 4 byte arrays, so its number 601a can be set to 1, byte array 2 is ranked second among the 4 byte arrays, so its number 602a can be set to 2, byte array 3 is ranked third among the 4 byte arrays, so its number can be set to 3, and byte array 4 is ranked fourth among the 4 byte arrays, so its number can be set to 4; obviously, the total number of fragments is 4.
[0173] Furthermore, if the verification range is a verification group range, the service device groups the four byte arrays according to the array positions corresponding to the four byte arrays, and obtains E byte array sets, such as Figure 7 As shown, in this step example, E is equal to 2. The service device divides byte array 1 and byte array 2 into the first byte array set, and divides byte array 3 and byte array 4 into the second byte array set. It can be understood that E is less than A. If E is equal to A, then the verification range is the verification fragment range.
[0174] Please see again Figure 7 , 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; will determine 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; will determine 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; 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.
[0175] Please see again Figure 7 If the verification range is the entire verification range, the business equipment will Figure 7 The four byte arrays in are all determined to be associated byte arrays associated with byte array 1; Figure 7 The four byte arrays in are all determined to be associated byte arrays associated with byte array 2; Figure 7 The four byte arrays in are all determined to be associated byte arrays associated with byte array 3; Figure 7 The four byte arrays in are all determined to be associated byte arrays associated with byte array 4.
[0176] 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.
[0177] Specifically, get the byte array B c F byte arrays in the byte array set; 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 concatenated to obtain an associated fragment data structure.
[0178] Specifically, 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.
[0179] Please see again Figure 7If the verification range is the verification group range, the service device performs concatenation processing on 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 the associated fragment data structure corresponding to both byte array 1 and byte array 2. Figure 7 Take the fragment data structure 1 as an example. Similarly, the service device concatenates the number corresponding to the byte array 3, the number corresponding to the byte array 4, the total number of fragments 60b, the byte array 3 and the byte array 4 to obtain the associated fragment data structure corresponding to both the byte array 3 and the byte array 4.
[0180] 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.
[0181] Step S205: determine the check code corresponding to the associated fragment data structure as byte array B c The corresponding check code.
[0182] Step S206, according to the byte array B c The number, the total number of fragments A and the 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.
[0183] 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 A program slices with legitimacy are used to indicate that the complete intermediate code is the same as the intermediate code corresponding to the smart contract.
[0184] For the specific implementation process of steps S205 to S207, please refer to the above Figure 3 The description of step S102 to step S103 in the corresponding embodiment will not be repeated here.
[0185] 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, the intermediate code corresponding to the smart contract. Therefore, by adopting the present application, there is no limit on the storage capacity occupied by the intermediate code corresponding to the smart contract, so the applicability of the smart contract deployment can be improved; in addition, the present application can avoid pre-installing the intermediate code corresponding to the smart contract on the blockchain node, so it 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.
[0186] For further information, see Figure 8 , Figure 8 This is a flow diagram of a data processing method provided in an embodiment of the present application. Figure 3 The method may be performed by a business server (eg, Figure 1 The service server 101 shown in the figure may also be executed by a terminal device (for example, the above Figure 1 The terminal device 100a shown in the figure can also be executed by a blockchain node (for example, the above Figure 1 The example blockchain node 10a) can also be 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 takes the method executed by the business device (specifically the business server or terminal device or the business server and terminal device) as an example for explanation. Figure 8 As shown, the method may at least include the following steps S301-S302.
[0187] Step S301, 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 that have been 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; one byte array is used for the business device to generate one program shard.
[0188] 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 processed for consensus to obtain a consensus result. If the consensus result is a consensus passing result, the block to be chained is processed for chaining; if the block to be chained is successfully chained, it is determined that the program shards are the program shards that have been chained, and the program shards that have been chained are obtained.
[0189] The program shards sent by the business device will be stored on the blockchain node, that is, packaged into blocks. One feasible way is to use blockchain transactions, and A program shards will be stored in all relevant blockchain nodes; another feasible way is to use program shard routing processing, and A program shards are only stored in some blockchain nodes. In the above two feasible ways, all relevant blockchain nodes or some relevant blockchain nodes can store all program shards.
[0190] There is also a feasible way to store different program shards for different blockchain nodes, for example, there are 3 program shards in total, wherein program shard 1 is packaged to block 1 by blockchain node 1, and when consensus on block 1 is passed, only blockchain node 1 stores program shard 1 in the local account book; program shard 2 is packaged to block 2 by blockchain node 2, and when consensus on block 2 is passed, only blockchain node 2 stores program shard 2 in the local account book; program shard 3 is packaged to block 3 by blockchain node 3, and when consensus on block 3 is passed, only blockchain node 3 stores program shard 3 in the local account book. 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 chained; 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 chained. 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.
[0191] Step S302, count the total number of program fragments that have been chained. If the total number is equal to the total number of fragments A, assemble the byte arrays respectively included in the A program fragments according to the serial numbers respectively included in the A program fragments to obtain a complete intermediate code.
[0192] Please also see Fig. 9 , Fig. 9 This is a flowchart of a data processing method based on blockchain provided in an embodiment of the present application. Figure 4 .like Fig. 9 As shown, the method includes steps S3021 to S3023.
[0193] Step S3021, obtain program fragments.
[0194] 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 chained can also be synchronized to other blockchain nodes.
[0195] Step S3022: Whether the total number of program slices obtained is equal to the total number of slices A.
[0196] 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 shards, it indicates that all program shards have been received, so program assembly can be performed.
[0197] 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.
[0198] Specifically, the complete smart contract program is processed by sharding according to the number, and the program shards received by the blockchain node may be out of order, so it is necessary to sort the byte arrays of the program shards according to the number to obtain the complete intermediate code. The blockchain node stores the complete intermediate code after assembly and recovery for subsequent decoding, calling and querying.
[0199] The above method also includes the following contents: 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 segmentation G h Included checksum, program segment G h Perform a legality check and obtain the verification result I h .
[0200] 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 include one or more program slices; the serial number, the total number of slices A and the byte array included in the associated program slices are concatenated to obtain a 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 .
[0201] 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 in A program slices, the program slice G h Determined to be with program slice G hIf the verification range is the verification range of the entire program, then A program slices are determined to be associated with program slice G. h The associated associated program slice; if the verification range is the verification group range, then obtain the program slice G h The number group carried by the included check code; the number group includes one or more numbers, and the number group includes program segment G h In the A program slices, the program slice corresponding to the number group is determined as the same as the program slice G h The associated associated program slice.
[0202] Among them, according to the data structure of the slice to be checked 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 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 h The included checksum is compared; if the hash value to be checked 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 .
[0203] Among them, according to the data structure of the slice to be checked 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 verification code included is a signature value, the device public key of the business device is obtained; through the device public key, the program segment G h The verification code included is used for signature verification processing 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 verification result is a failed verification result, the verification failure result is determined as verification result I h .
[0204] The above method also includes the following contents: if the verification results corresponding to the A program slices are all verification passing results, then the complete intermediate code is stored; 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.
[0205] 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, the intermediate code corresponding to the smart contract. Therefore, by adopting the present application, there is no limit on the storage capacity occupied by the intermediate code corresponding to the smart contract, so the applicability of the smart contract deployment can be improved; in addition, the present application can avoid pre-installing the intermediate code corresponding to the smart contract on the blockchain node, so it 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.
[0206] For further information, see Fig.10 , Fig.10 This is a schematic diagram of a data processing device based on blockchain provided in an embodiment of the present application. Figure 1 .like Fig.10 As shown, the blockchain-based data processing device 1 can be run on a business device. The above-mentioned blockchain-based data processing device 1 can be a computer program (including program code) running in 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. Fig.10 As shown, the blockchain-based data processing device 1 may include: a code processing module 11, a shard generation module 12 and a shard sending module 13.
[0207] The code processing module 11 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 byte arrays include byte array B c , c is a positive integer and c is less than or equal to A;
[0208] The fragment generation module 12 is used to generate a fragment according to the byte array B c The number, the total number of fragments A and the byte array B c , generate program fragment D c ;
[0209] The fragment sending module 13 is used to send the program fragments corresponding to the A byte arrays 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.
[0210] 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 the above Figure 3 The steps S101 to S103 in the corresponding embodiment will not be described in detail here.
[0211] See also 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.
[0212] The first processing unit 111 is used to encode the source code corresponding to the smart contract, obtain the intermediate code corresponding to the smart contract, and obtain the storage capacity occupied by the intermediate code corresponding to the smart contract;
[0213] The first acquisition unit 112 is used to acquire the block storage capacity, and compare 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;
[0214] The second processing unit 113 is used to slice 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.
[0215] The specific functional implementation of the first processing unit 111, the first acquisition unit 112 and the second processing unit 113 can be found in the above Figure 3 The step S101 in the corresponding embodiment will not be described in detail here.
[0216] See also Fig.10 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.
[0217] The first generating unit 121 is used to generate a byte array B according to the c Generate byte array B at array position in byte array A c The corresponding number;
[0218] The first determining unit 122 is used to determine a 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;
[0219] The third processing unit 123 is used to perform concatenation processing on 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;
[0220] The second determining unit 124 is used to determine the check code corresponding to the associated fragment data structure as a byte array B c The corresponding check code.
[0221] 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 be referred to above. Figure 6 Steps S202 to S205 in the corresponding embodiment are not described in detail here.
[0222] See also Fig.10 , the first determining unit 122 may include: a first determining subunit 1221.
[0223] The first determining subunit 1221 is used 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;
[0224] The third processing unit 123 may include: a first processing sub-unit 1231 .
[0225] The first processing subunit 1231 is used to process the byte array B c The corresponding number, total number of slices A and byte array B c Perform splicing processing to obtain the associated shard data structure.
[0226] The specific functional implementation of the first determining subunit 1221 and the first processing subunit 1231 can be found in the above Figure 6 Steps S203 and S204 in the corresponding embodiment will not be described in detail here.
[0227] See also Fig.10 , the first determining unit 122 may include: a second processing subunit 1222 and a second determining subunit 1223.
[0228] The second processing sub-unit 1222 is used for grouping the A byte arrays according to the array positions corresponding to the A byte arrays to obtain E byte array sets if the check range is a check group range; E is a positive integer greater than 1 and less than A.
[0229] 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 as the byte array B c the associated associative byte array;
[0230] The third processing unit 123 may include: an array acquiring subunit 1232 and a third processing subunit 1233 .
[0231] The array acquisition subunit 1232 is used to acquire the byte array B cF byte arrays in the byte array set; F is a positive integer, and F is less than A;
[0232] The third processing sub-unit 1233 is used to perform concatenation processing on the serial 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.
[0233] The specific functional implementation of the second processing subunit 1222, the second determining subunit 1223, the array obtaining subunit 1232 and the third processing subunit 1233 can be found in the above Figure 6 Steps S203 and S204 in the corresponding embodiment will not be described in detail here.
[0234] See also Fig.10 , the first determining unit 122 may include: a third determining subunit 1224.
[0235] The third determining subunit 1224 is used to determine the A byte arrays as being consistent with the byte array B if the verification range is the entire verification range. c the associated associative byte array;
[0236] Then the third processing unit 123 may include: a fourth processing sub-unit 1234 .
[0237] The fourth processing sub-unit 1234 is used 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.
[0238] The specific functional implementation of the third determining subunit 1224 and the fourth processing subunit 1234 can be found in the above Figure 6 Steps S203 and S204 in the corresponding embodiment will not be described in detail here.
[0239] See also Fig.10 The fragment generation module 12 may include: a fourth processing unit 126 and a second acquisition unit 127.
[0240] 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
[0241] The second acquisition unit 127 is used to acquire the device private key of the service device, and use the device private key to sign the associated shard data structure to 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.
[0242] The specific functional implementation of the fourth processing unit 126 and the second acquisition unit 127 can be found in the above Figure 3 The step S102 in the corresponding embodiment will not be described in detail here.
[0243] 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, the intermediate code corresponding to the smart contract. Therefore, by adopting the present application, there is no limit on the storage capacity occupied by the intermediate code corresponding to the smart contract, so the applicability of the smart contract deployment can be improved; in addition, the present application can avoid pre-installing the intermediate code corresponding to the smart contract on the blockchain node, so it 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.
[0244] For further information, see Fig.11 , Fig.11 This is a schematic diagram of a data processing device based on blockchain provided in an embodiment of the present application. Figure 2 .like Fig.11 As shown, the blockchain-based data processing device 2 can run on a blockchain node. The blockchain-based data processing device 2 can be a computer program (including program code) running in 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. Fig.11 As shown, the blockchain-based data processing device 2 may include: a shard acquisition module 21 and an array assembly module 22.
[0245] The shard acquisition module 21 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 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; one byte array is used by the business device to generate one program shard;
[0246] 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 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.
[0247] The specific functional implementation of the slice acquisition module 21 and the array assembly module 22 can be found in the above Figure 8 The steps S301 and S302 in the corresponding embodiment will not be described in detail here.
[0248] See also Fig.11 , A program slices include program slice G h , h is a positive integer, and h is less than or equal to A;
[0249] The blockchain-based data processing device 2 may further include: a shard verification module 23 and a code storage module 24.
[0250] The fragmentation verification module 23 is used to fragment G according to the program. h Included checksum, program segment G h Perform a legality check and obtain the verification result I h ;
[0251] 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.
[0252] The specific functional implementation of the fragmentation verification module 23 and the code storage module 24 can be found in the above Figure 8 The step S302 in the corresponding embodiment will not be described in detail here.
[0253] See also Fig.11 The fragmentation verification module 23 may include: a first determination unit 231, a first processing unit 232 and a second determination unit 233.
[0254] The first determining unit 231 is used to determine a verification range, and determine the program slice G in the A program slices according to the verification range. h An associated associated program slice; the associated program slice includes one or more program slices;
[0255] The first processing unit 232 is used to perform concatenation processing on the serial number of the associated program slice, the total number of slices A, and the byte array included in the associated program slice to obtain a slice data structure to be checked;
[0256] The second determining unit 233 is used to determine the slice data structure to be checked and the program slice G h Included check code, determine the check result I h .
[0257] 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 the above Figure 8 The step S302 in the corresponding embodiment will not be described in detail here.
[0258] See also Fig.11The 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.
[0259] 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 slice G h associated associated program slices;
[0260] 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 verification range of the entire program slice. h associated associated program slices;
[0261] 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 segment G h The number in;
[0262] The third determining subunit 2314 is used to determine the program slice corresponding to the number group as the same as the program slice G among the A program slices. h The associated associated program slice.
[0263] 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 be found in the above Figure 8 The step S302 in the corresponding embodiment will not be described in detail here.
[0264] See also Fig.11 The second determination unit 233 may include: a first processing subunit 2331 , a verification and comparison subunit 2332 , a fourth determination subunit 2333 , and a fifth determination subunit 2334 .
[0265] The first processing subunit 2331 is used to h If the included check code is a hash value, the shard data structure to be checked is hashed to obtain the hash value to be checked;
[0266] Verification and comparison subunit 2332, used to verify the hash value and program fragment G h The included checksum is compared;
[0267] The fourth determining subunit 2333 is used to determine whether 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 Ih ;
[0268] The fifth determining subunit 2334 is used to determine whether the hash value to be verified and the program segment G h If the verification code included is different, the verification failure result is determined as the verification result I h .
[0269] The specific functional implementation 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 referred to above. Figure 8 The step S302 in the corresponding embodiment will not be described in detail here.
[0270] See also 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 .
[0271] The second acquisition subunit 2335 is used to h If the included verification code is a signature value, the device public key of the business device is obtained;
[0272] The second processing subunit 2336 is used to process the program segment G using the device public key. h The included verification code is used for signature verification to obtain the verification result;
[0273] The sixth determining subunit 2337 is configured to determine the verification pass result as the verification result I if the verification result is a successful verification result. h ;
[0274] 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 .
[0275] 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 the above Figure 8 The step S302 in the corresponding embodiment will not be described in detail here.
[0276] See also 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.
[0277] The shard acquisition unit 211 is used to acquire the program shards initiated by the business device and pack the program shards into a block to be uploaded to the chain;
[0278] 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 passing result, the block to be put on the chain is put on the chain;
[0279] 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.
[0280] 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 the above Figure 8 The step S301 in the corresponding embodiment will not be described in detail here.
[0281] 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, the intermediate code corresponding to the smart contract. Therefore, by adopting the present application, there is no limit on the storage capacity occupied by the intermediate code corresponding to the smart contract, so the applicability of the smart contract deployment can be improved; in addition, the present application can avoid pre-installing the intermediate code corresponding to the smart contract on the blockchain node, so it 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.
[0282] For further information, see Fig.12 , Fig.12 Schematic diagram of the structure of a computer device provided in an embodiment of the present application. Fig.12 As shown, 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. The communication bus 1002 is used to realize the connection and communication between these components. In some embodiments, the user interface 1003 may include a display screen (Display) and a keyboard (Keyboard), and the network interface 1004 may optionally include a standard wired interface and 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 FIG. Fig.12 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a device control application.
[0283] exist Fig.12 In the computer device 1000 shown, the network interface 1004 can provide a network communication function; 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 device control application stored in the memory 1005 to achieve:
[0284] 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; A byte arrays include byte array B c , c is a positive integer and c is less than or equal to A;
[0285] According to the byte array B c The number, the total number of fragments A and the byte array B c , generate program fragment D c ;
[0286] The program slices corresponding to the A byte arrays 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 on the chain are used to be assembled to generate a complete intermediate code.
[0287] Alternatively, the processor 1001 may be configured to call a device control application stored in the memory 1005 to implement:
[0288] 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; one byte array is used by the business device to generate one program shard;
[0289] 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, assemble the byte arrays included in the A program fragments according to the serial numbers included in the A program fragments to obtain the complete intermediate code.
[0290] It should be understood that the computer device 1000 described in the embodiment 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 adopting the same method will not be repeated.
[0291] The present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the description of the data processing method or device in the above embodiments is implemented, which will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated.
[0292] 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 memory card (smart media card, SMC), a secure digital (secure digital, SD) card, a flash card (flash card), etc. equipped on the computer device. Further, 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.
[0293] The present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device 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 the same method will not be repeated.
[0294] 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 term "comprising" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, device, product, or equipment that includes a series of steps or units is not limited to the listed steps or modules, but optionally includes steps or modules that are not listed, or optionally includes other step units inherent to these processes, methods, devices, products, or equipment.
[0295] Those of ordinary skill 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.
[0296] The above disclosure is only the preferred embodiment of the present application, which 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 to obtain A byte arrays; A is a positive integer greater than 1; the A byte arrays include byte array B 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 fragments A and the byte array B c , generate program fragment D c ; The program slices corresponding to the A byte arrays 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, characterized in that According to the byte array B c The number, the total number of fragments 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 According to the verification range, determine in the A byte arrays the value corresponding to the byte array B 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 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: According to the verification range, determine in the A byte arrays the value corresponding to the byte array B 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 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: Get the byte array B c F byte arrays in 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 According to the verification range, determine in the A byte arrays the value corresponding to the byte array B 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 claim 3, 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 slice initiated by the business device and uploaded to the chain, and obtain the total number of slices A in the program slice uploaded to the chain; A is a positive integer greater than 1; the business device is used to slice the intermediate code corresponding to the smart contract to obtain A byte arrays; one byte array is used for the business device to generate one program slice; 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 A program slices include program slice G h , h is a positive integer, and h is less than or equal to A; The method further comprises: According to the program, slice G h The checksum included in the program segment G h Perform a legality check and obtain the verification result I h ; If the verification results corresponding to the A program slices are all passed verification results, the complete intermediate code is stored; the A verification results that are all passed verification results are 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 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 The number in; Among the A program slices, the program slice corresponding to the number group is determined as the same as the program slice G. h The associated associated program slice.
12. The method according to claim 10, 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, 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 segmented 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 claim 8, 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 intermediate code corresponding to the smart contract is sliced to obtain A byte arrays; A is a positive integer greater than 1; the A byte arrays include byte array B c , c is a positive integer and c is less than or equal to A; Generates the byte array B including the c The number of the slices, the total number of slices A, the byte array B c and the byte array B c Corresponding checksum program fragment D c ; The program segment D c The storage capacity occupied is less than the block storage capacity in the blockchain; The program is divided into D c Send it to the blockchain network so that the blockchain nodes in the blockchain network can share the program shard D c The blockchain node is used to assemble the byte arrays respectively included in the A program slices through the numbers respectively included in the A program slices when the total number of program slices that have been chained is A, so as to obtain 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 A program slices with legitimacy are used to indicate that the complete intermediate code is the same as the intermediate code corresponding to the smart contract.
16. A data processing device based on blockchain, characterized in that: The device runs on a blockchain node, and the device includes: Obtain the program slice initiated by the business device and uploaded to the chain, and obtain the total number of slices A in the program slice uploaded to the chain; A is a positive integer greater than 1; the business device is used to slice the intermediate code corresponding to the smart contract to obtain A byte arrays; one byte array is used for the business device to generate one program slice; Count the total number of program shards on the chain. If the total number is equal to the total number of shards A, assemble the byte arrays respectively included in the A program shards according to the serial numbers respectively included in the A program shards to obtain a complete intermediate code; the storage capacity occupied by the A program shards is less than the block storage capacity in the blockchain; the A program shards include program shard G h , h is a positive integer, and h is less than or equal to A; According to the program, slice G h The checksum included in the program segment G h Perform a legality check and obtain the verification result I h ; If the verification results corresponding to the A program slices are all passed verification results, the complete intermediate code is stored; the A verification results that are all passed verification results are used to indicate that the complete intermediate code is the same as the intermediate code corresponding to the smart contract.
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 method described in 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, and the computer program is suitable for being loaded and executed by a processor, so that a computer device having the processor executes the method according to any one of claims 1 to 14.
19. A computer program product, characterized in that The computer program product comprises a computer program, which is stored in a computer-readable storage medium. The computer program is suitable for being read and executed by a processor, so that a computer device having the processor executes the method according to any one of claims 1 to 14.
Citation Information
Cited By
Data processing method based on blockchain, and device and readable storage medium
EP4700567A1