Data processing method and device based on block chain, equipment and storage medium
By checking and approving smart contract update requests in the blockchain network, automatically rolling on the link and calling proxy contracts for updates, the problem of low efficiency and security of smart contract updates is solved, and automated updates and high security are achieved.
Patent Information
- Application Number
- CN202311551928.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-20
- Publication Date
- 2025-05-20
AI Technical Summary
In the existing technology, smart contract update efficiency and security are low. Developers need to manually write the underlying code, and the security of the updated smart contract is difficult to guarantee and is prone to failure of updates.
By obtaining the attribute information of the smart contract to be updated in the blockchain network, verifying the legality of the smart contract, generating a contract update request, sending it to the signature object for approval, receiving the confirmation of the signature will be updated on the chain, and calling the proxy smart contract for updates.
Automatic update of smart contracts is realized, update efficiency is improved, the stability and reliability of updates are ensured, security is enhanced, and illegal updates are avoided.
Smart Images

Figure CN120020782A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of blockchain technology, and in particular to a data processing method, device, equipment and storage medium based on blockchain. Background Art
[0002] Blockchain technology is a new distributed infrastructure and computing method that uses a block chain data structure to verify and store data, uses a distributed node consensus algorithm to generate and update data, uses cryptography to ensure the security of data transmission and access, and uses smart contracts composed of automated script codes to program and operate data. Simply put, blockchain is a decentralized distributed ledger. Among them, the smart contract in the blockchain is a computer protocol designed to spread, verify or execute a contract in an information-based manner. Smart contracts allow for trusted transactions without a third party, and these transactions are queryable and irreversible. A smart contract is actually a piece of executable code that executes user transactions in an independent, secure and reliable environment.
[0003] Currently, developers need to write the underlying code for each smart contract by themselves to implement the contract update of the smart contract, which requires high technical requirements for developers' code writing, is time-consuming and laborious, and it is difficult to guarantee the security of the updated smart contract and it is easy to update failure, resulting in low efficiency and security of smart contract update. Summary of the Invention
[0004] The embodiments of this application provide a data processing method, device, equipment and storage medium based on blockchain, which can improve the efficiency and security of smart contract update.
[0005] On the one hand, the embodiments of this application provide a data processing method based on blockchain, including:
[0006] Obtain the first contract attribute information of the original smart contract to be updated in the blockchain network, and the second contract attribute information of the updated smart contract of the original smart contract;
[0007] According to the first contract attribute information and the second contract attribute information, verify the update legality of the updated smart contract to obtain a legality verification result;
[0008] If the legality verification result indicates that the updated smart contract has update legality, then generate a contract update request for indicating to update the original smart contract with the updated smart contract, and send the contract update request to a signature object associated with the original smart contract; the signature object is used to generate an update confirmation signature according to the contract update request;
[0009] Receive the update confirmation signature returned by the signature object, and according to the received update confirmation signature, upload the updated smart contract to the blockchain of the blockchain network;
[0010] Invoke the proxy smart contract corresponding to the original smart contract, and update the original smart contract according to the updated smart contract.
[0011] In one aspect, an embodiment of the present application provides a blockchain-based data processing device, including:
[0012] A first acquisition module, configured to acquire first contract attribute information of an original smart contract to be updated in a blockchain network, and second contract attribute information of an updated smart contract of the original smart contract;
[0013] A verification module, configured to verify the update legality of the updated smart contract according to the first contract attribute information and the second contract attribute information, and obtain a legality verification result;
[0014] A sending module, configured to generate a contract update request for instructing to update the original smart contract with the updated smart contract and send the contract update request to a signature object associated with the original smart contract if the legality verification result indicates that the updated smart contract has update legality; the signature object is configured to generate an update confirmation signature according to the contract update request;
[0015] An on-chain module, configured to receive the update confirmation signature returned by the signature object, and on-chain the updated smart contract to the blockchain of the blockchain network according to the received update confirmation signature;
[0016] An update module, configured to invoke the proxy smart contract corresponding to the original smart contract, and update the original smart contract according to the updated smart contract.
[0017] In one aspect, an embodiment of the present application provides a computer device, including: a processor and a memory;
[0018] The processor is connected to the memory. The memory is configured to store a computer program. When the computer program is executed by the processor, the computer device executes the method provided by the embodiment of the present application.
[0019] In one aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which is adapted to be loaded and executed by a processor so that a computer device having the processor executes the method provided by the embodiment of the present application.
[0020] In one aspect, an embodiment of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method provided by the embodiment of the present application.
[0021] In the embodiments of the present application, a pipeline service for automatic update of smart contracts is provided. While realizing the automatic update of the original smart contracts, the security of the update of the original smart contracts can also be ensured. Specifically, the present application includes but is not limited to the following beneficial effects: First, it realizes the automatic update of smart contracts, and business objects do not need to write underlying code for each smart contract to implement the contract update of the smart contract, saving time and effort and improving the efficiency of smart contract update. Second, by verifying the legality of the update of the updated smart contract, it is possible to avoid the situation where the updated smart contract contains malicious attack code or the updated smart contract is incompatible with the original smart contract, resulting in update failure, and the stability and reliability of the update of the original smart contract can be ensured. Third, the approval of the update of the original smart contract by the signature object can further improve the security and reliability of the update of the original smart contract and avoid the update of the original smart contract by illegal objects. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0023] Figure 1a It is a schematic diagram of a blockchain structure provided by an embodiment of the present application;
[0024] Figure 1b It is a schematic diagram of block generation provided by an embodiment of the present application;
[0025] Figure 2 It is a schematic diagram of the structure of a data processing system based on a blockchain provided by an embodiment of the present application;
[0026] Figure 3 It is a schematic diagram of a hierarchical structure of a blockchain network provided by an embodiment of the present application;
[0027] Figure 4 It is a schematic diagram of a blockchain network applied to smart contract update provided by an embodiment of the present application;
[0028] Figure 5 It is a schematic diagram of the application of a hierarchical structure of a blockchain network provided by an embodiment of the present application;
[0029] Figure 6 It is a schematic diagram of a scenario for automatic update of an original smart contract provided by an embodiment of the present application;
[0030] Figure 7It is the first schematic flowchart of a data processing method based on a blockchain provided by an embodiment of the present application;
[0031] Figure 8 It is the schematic flowchart of a data processing method based on a blockchain provided by an embodiment of the present application Figure II ;
[0032] Figure 9 It is the schematic structural diagram of a data processing device based on a blockchain provided by an embodiment of the present application;
[0033] Figure 10 It is the schematic diagram of a computer device provided by an embodiment of the present application. Specific embodiments
[0034] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0035] The present application relates to the field of artificial intelligence technology. Specifically, in the embodiments of the present application, the security of the updated smart contract can be detected through a contract security detection model, and the accuracy and efficiency of the security detection of the smart contract can be updated.
[0036] Among them, artificial intelligence (AI) is to use a digital computer or a machine controlled by a digital computer to simulate, extend, and expand human intelligence, and is a theory, method, technology, and application system that perceives the environment, acquires knowledge, and uses knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science. It attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a way similar to human intelligence. Artificial intelligence also studies the design principles and implementation methods of various intelligent machines, enabling the machines to have the functions of perception, reasoning, and decision-making. Artificial intelligence technology is an interdisciplinary subject, involving a wide range of fields, including both hardware-level technologies and software-level technologies. The basic technologies of artificial intelligence generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, large voice data processing technology, operation / interaction systems, and mechatronics. The software technologies of artificial intelligence mainly include several major directions such as computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning, autonomous driving, and intelligent transportation.
[0037] Specifically, this application specifically relates to machine learning under artificial intelligence technology. Machine Learning (ML) is an interdisciplinary field that involves multiple disciplines such as probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers simulate or implement human learning behaviors to acquire new knowledge or skills and reorganize the existing knowledge structure to continuously improve their own performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent, and its applications cover all fields of artificial intelligence. Machine learning and deep learning usually include technologies such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and rote learning.
[0038] This application relates to blockchain, which is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithms. Essentially, blockchain is a decentralized database, a series of data blocks generated by using cryptographic methods. Each data block contains information about a batch of network transactions, which is used to verify the validity of the information (anti-counterfeiting) and generate the next block. Blockchain can include the blockchain underlying platform, the platform product service layer, and the application service layer. Blockchain consists of multiple blocks. Refer to Figure 1a , Figure 1a which is a schematic diagram of a blockchain structure provided by an embodiment of this application. As shown in Figure 1a , blockchain consists of multiple blocks. The genesis block includes a block header and a block body. The block header stores the input information feature value, version number, timestamp, and difficulty value, and the block body stores the input information. The next block of the genesis block uses the genesis block as its parent block. The next block also includes a block header and a block body. The block header stores the input information feature value of the current block, the block header feature value of the parent block, version number, timestamp, and difficulty value, and so on. This ensures that the block data stored in each block in the blockchain is associated with the block data stored in the parent block, guaranteeing the security of the input information in the block.
[0039] When generating each block in the blockchain, refer to Figure 1b , Figure 1b which is a schematic diagram of block generation provided by an embodiment of this application. When the node where it is located receives the input information, it verifies the input information. After the verification is completed, it stores the input information in the memory pool and updates the hash tree used to record the input information. Then, it updates the timestamp to the time when the input information is received and tries different random numbers, performing eigenvalue calculations multiple times so that the calculated eigenvalue can satisfy the following formula:
[0040] SHA256(SHA256(version + prev_hash + merkle_root + ntime + nbits + x)) < TARGET
[0041] Among them, SHA256 in the formula is the eigenvalue algorithm used to calculate the eigenvalue; version (version number) is the version information of the relevant block protocol in the blockchain; prev_hash is the block header eigenvalue of the parent block of the current block; merkle_root is the eigenvalue of the input information; ntime is the update time for updating the timestamp; nbits is the current difficulty, which is a fixed value within a certain period of time and is determined again after exceeding the fixed time period; x is a random number; TARGET is the eigenvalue threshold, and this eigenvalue threshold can be determined according to nbits.
[0042] Among them, when a random number that satisfies the above formula is calculated, the information can be stored correspondingly to generate a block header and a block body, obtaining the current block. Subsequently, the blockchain can broadcast the newly generated current block externally, that is, send the current block to other nodes in the data sharing system where it is located. Each node in the data sharing system stores an identical blockchain, and other nodes verify the current block and add the current block to the blockchain they store after the verification is completed.
[0043] Please refer to Figure 2 , Figure 2 which is a schematic structural diagram of a data processing system based on blockchain provided by an embodiment of the present application. As Figure 2As shown, the blockchain-based data processing system may include a blockchain network 1X and a cluster of terminal devices 1Y. Among them, the blockchain network 1X may include: blockchain nodes 200a, blockchain nodes 200b, blockchain nodes 200c... and blockchain nodes 200n. It can be understood that the blockchain network 1X may include one or more blockchain nodes, and the number of blockchain nodes is not limited in the embodiments of this application. It can be understood that in this blockchain network 1X, data interaction can be carried out between the blockchain nodes 200a, blockchain nodes 200b, blockchain nodes 200c... and blockchain nodes 200n through network connections. It should be understood that each blockchain node in the blockchain network 1X (for example, blockchain nodes 200a, blockchain nodes 200b, blockchain nodes 200c... and blockchain nodes 200n) can be used to maintain the same blockchain. A peer-to-peer network can be formed between any two blockchain nodes in this blockchain network 1X, and the peer-to-peer network can adopt a peer-to-peer transmission protocol. Among them, the peer-to-peer transmission protocol is an application layer protocol running on top of the Transmission Control Protocol (TCP). In a distributed system, any device such as a server, a terminal, etc. can join and become a blockchain node.
[0044] Among them, the cluster of terminal devices 1Y may include one or more terminal devices, and the number of terminal devices will not be limited here. As Figure 2 shown, it may specifically include terminal devices 100a, terminal devices 100b, terminal devices 100c,..., terminal devices 100n. As Figure 2 shown, the terminal devices 100a, terminal devices 100b, terminal devices 100c,..., terminal devices 100n can be respectively network-connected to the blockchain nodes (such as blockchain node 200a) in the blockchain network 1X, so that each terminal device can perform data interaction with the blockchain nodes in the blockchain network 1X through this network connection. Among them, the blockchain nodes in the blockchain network 1X can be the backend servers of the terminal devices in the cluster of terminal devices 1Y.
[0045] Among them, each terminal device in the cluster of terminal devices 1Y can include: intelligent terminals with blockchain-based data processing functions such as smartphones, tablets, laptops, desktop computers, intelligent voice interaction devices, intelligent home appliances (such as intelligent TVs), wearable devices, in-vehicle terminals, etc. It should be understood that, as Figure 2 shown, each terminal device in the cluster of terminal devices 1Y can be installed with an application client with blockchain-based data processing functions. When the application client runs on each terminal device, it can be respectively connected to the above-mentioned Figure 2Data interaction is carried out among blockchain nodes (such as blockchain node 200a) in the blockchain network 1X shown. It can be understood that, through an application client in the terminal device with blockchain-based data processing capabilities, relevant business transactions regarding smart contracts in the above blockchain network can be sent to the blockchain nodes in the blockchain network 1X. For example, the application client can specifically include a smart contract management client, a smart contract update client, etc. Among them, the application client in the embodiments of this application can be integrated in a certain application client (such as the smart contract update client is integrated in the smart contract management client), and the application client can also be an independent application client. The embodiments of this application do not limit the type of the application client.
[0046] For ease of understanding, in the embodiments of this application, Figure 2 one of the multiple terminal devices shown can be selected as the target terminal device. For example, in the embodiments of this application, Figure 2 the terminal device 100a shown can be used as the target terminal device. The target terminal device can be installed with an application client with blockchain-based data processing capabilities. At this time, the target terminal device can, through this application client, send relevant business transactions regarding smart contracts in the above blockchain network to the blockchain nodes in the blockchain network 1X.
[0047] It should be noted that all node devices in the blockchain network involved in the embodiments of this application can be mobile phones, tablet computers, laptop computers, palmtop computers, mobile internet devices (MIDs), vehicles, roadside devices, aircraft, wearable devices, such as smart watches, smart bracelets, pedometers, etc., which are intelligent devices with data processing capabilities. All node devices in the blockchain network can also be independent physical servers, or a server cluster or distributed system composed of multiple physical servers, or cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDNs (Content Delivery Networks), and big data and artificial intelligence platforms. The device types corresponding to each node device can be the same or different.
[0048] Among them, the smart contract on the blockchain is a computer protocol designed to spread, verify, or execute a contract in an information-based manner. The smart contract allows for trustworthy transactions without a third party, and these transactions are queryable and irreversible. The smart contract is actually an executable piece of code that executes user transactions in an independent, secure, and reliable environment. Due to the immutable nature of the blockchain, once the original smart contract on the blockchain is deployed, it cannot be changed. Therefore, when updating the contract of the original smart contract on the blockchain, the contract content of the original smart contract is not changed. Instead, an updated smart contract for updating the original smart contract is deployed on the blockchain, and the contract address of the updated smart contract on the blockchain is obtained as the updated contract address. The contract address of the updated smart contract is notified to the calling object of the original smart contract, and at the same time, the calling object of the original smart contract is notified to no longer call the original contract address of the original smart contract but to call the updated contract address of the updated smart contract, thereby realizing the update service of the original smart contract.
[0049] For ease of subsequent understanding and description, an embodiment of the present application may select a terminal device as the target terminal device from the Figure 2 terminal cluster shown. For example, the terminal device 100a is used as the target terminal device. A smart contract management client is installed in the terminal device 100a, and the smart contract management client is used to handle related services of the smart contract, such as the trigger detection service of the smart contract, the automatic execution service of the smart contract, the update service of the smart contract (such as the upgrade service), and other services. A service object (such as an object that needs to update the original smart contract in the blockchain network) may submit an updated smart contract for updating the original smart contract to be updated in the smart contract management client in the terminal device 100a. In this way, it is possible to avoid the service object writing its own underlying proxy to implement the contract update of the original smart contract, and the update efficiency of the original smart contract update can be improved.
[0050] Specifically, the terminal device 100a can obtain the first contract attribute information of the original smart contract and the second contract attribute information of the updated smart contract, and verify the update legality of the updated smart contract according to the first contract attribute information and the second contract attribute information to obtain a legality verification result. Among them, both the first contract attribute information and the second contract attribute information can refer to contract identification information, contract code information, contract log data, contract data structure, etc. Only when the updated smart contract has update legality, a contract update request for instructing to update the original smart contract with the updated smart contract is generated. In this way, verifying the update legality of the updated smart contract can avoid problems such as low security and reliability when the updated smart contract does not have update legality (such as the updated smart contract has code defects and cannot run, the updated smart contract has illegal attack code, the updated smart contract has a large number of repeated code steps to consume user transaction fees (i.e., transaction gas), etc.), resulting in contract update failure or causing great losses to contract call objects.
[0051] The terminal device 100a can send the contract update request to a signature object associated with the original smart contract. The signature object associated with the original smart contract can refer to the management object of the original smart contract, or an object set by the management object of the original smart contract. The number of signature objects can be a positive integer. Since smart contract update is a relatively important operation, once the smart contract is updated, it will affect the operation of the business related to the smart contract. Therefore, approving the update of the original smart contract through the signature object associated with the original smart contract can improve the security and reliability of the original smart contract update. The signature object can approve the contract update request. When confirming the contract update request, sign the contract update request to obtain an update confirmation signature and return the update confirmation signature to the terminal device 100a.
[0052] The terminal device 100a can receive the updated confirmation signature returned by the signature object, and based on the received updated confirmation signature, upload the updated smart contract to the blockchain of the blockchain network. In this way, by having the signature object approve the update of the original smart contract, the security and reliability of the update of the original smart contract can be improved. The terminal device 100a invokes the proxy smart contract corresponding to the original smart contract and updates the original smart contract according to the updated smart contract. It can be seen that in this application, the original smart contract can be updated according to the updated smart contract, and the business object does not need to write the underlying proxy by itself to implement the contract update of the original smart contract, which can improve the update efficiency of the update of the original smart contract. At the same time, the legality of the update of the updated smart contract is verified. Only when it is determined that the updated smart contract has update legality, a contract update request is initiated. In this way, situations where the updated smart contract is maliciously attacked or tampered with can be avoided, and the stability and reliability of the update of the original smart contract can be ensured. In addition, the signature object associated with the original smart contract approves the update of the original smart contract, further ensuring the security of the update of the original smart contract.
[0053] Please refer to Figure 3 , Figure 3 which is a schematic diagram of a hierarchical structure of a blockchain network provided by an embodiment of this application. The network structure of the above blockchain network 1X in the embodiment of this application can be Figure 3 the hierarchical structure of the blockchain network shown in the figure. The complete blockchain business system corresponding to this blockchain network 1X can be composed of Figure 3 the business network, the core consensus network, and the routing proxy network where the proxy node 10D is located as shown in the figure.
[0054] It should be understood that the number of proxy nodes in this routing proxy network can be one or more, which is not limited here. In the embodiment of this application, the proxy node 10D is taken as an example. The proxy node 10D can be used to isolate the network between the business network and the core consensus network. The proxy node 10D 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 services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms, which is not limited here. The proxy node 10D can layer the peer-to-peer network to form a hierarchical structure of "business network - core consensus network", thereby being able to improve the confidentiality and security of data on the blockchain.
[0055] Among them, Figure 3The blockchain node system corresponding to the business network (i.e., the witness network) shown may include one or more blockchain nodes, and the number of nodes in the blockchain node system corresponding to the business network will not be limited here. For example, the blockchain node system corresponding to the business network may specifically include node 200a, node 200b, node 200c, …, node 200n. It should be understood that in the embodiments of the present application, the blockchain nodes in the business network can be called business nodes, and these business nodes do not need to participate in the accounting consensus and are mainly used to execute transaction services to obtain transaction data associated with the transaction services. Among them, the business nodes here can be full nodes containing a complete blockchain database or lightweight nodes storing part of the data in the blockchain database, and no limitation will be made here. To reduce the waste of storage space of the business nodes, in the embodiments of the present application, the business nodes can take lightweight nodes (Simplified Payment Verification, abbreviated as SPV) as an example. These business nodes do not need to store complete transaction data, but through proxy node 10D, from Figure 3 the core consensus network shown, obtain block header data and partially authorized visible block data (for example, transactions associated with the business node itself).
[0056] Among them, Figure 3 the blockchain node system corresponding to the core consensus network shown may also include one or more blockchain nodes, and the number of nodes in the blockchain node system corresponding to the core consensus network will not be limited here. For example, the blockchain node system corresponding to the core consensus network may specifically include node 210a, node 210b, node 210c, …, node 210m. It should be understood that in the embodiments of the present application, the nodes in this core consensus network can be called consensus nodes (i.e., accounting nodes), and these consensus nodes can run a blockchain consensus protocol.
[0057] It should be understood that in the embodiments of the present application, the proxy nodes, business nodes, and consensus nodes can be collectively referred to as the blockchain nodes in the blockchain network 1X. Among them, the blockchain nodes can be servers connected to the blockchain network 1X or user terminals connected to the blockchain network 1X, and no specific form of the blockchain nodes is limited here. It can be understood that, Figure 3The business network and the core consensus network shown can be in different network environments. For example, generally, business nodes are deployed in the business network in the public network, while consensus nodes running the blockchain consensus protocol are deployed in the private core consensus network, and the two can interact through the routing boundary. In this application, the node that executes the update transaction of the original smart contract can be a business node in the above-mentioned business network, and the node that conducts consensus on the update transaction of the original smart contract can be a consensus node in the above-mentioned core consensus network, so as to form a hierarchical structure of "business network - core consensus network", thereby improving the confidentiality and security of data on the blockchain.
[0058] As Figure 4 shown, Figure 4 is a schematic diagram of applying a blockchain network to smart contract update provided by an embodiment of this application. As Figure 4 shown, the blockchain network includes a business network 41, a routing proxy network 42, and a core consensus network 43. Among them, the terminal device can access the business network 41 and upload an updated smart contract that needs to update the original smart contract. The business nodes in the business network 41 can perform operations such as contract compilation, contract verification (such as update validity verification), and contract update on the updated smart contract. The business nodes in the business network 41 can send contract on-chain transactions for the updated smart contract or update transactions of the original smart contract to the core consensus network 43 through the routing proxy network 42.
[0059] It can be understood that any routing node in the routing proxy network 42 includes functional modules that provide authentication service 421, certificate cache 422, routing service 423, and peer-to-peer service 424. The authentication service 421 is used to authenticate the business nodes in the business network 41. The certificate cache 422 is used to cache the identity certificates of each node. The routing service 423 is used to implement network isolation between the business network 41 and the core consensus network 43. The peer-to-peer service 424 is used to allocate tasks among routing nodes with idempotency, and a peer-to-peer network is formed among the routing nodes. The peer-to-peer protocol is an application layer protocol running on top of the Transmission Control Protocol (TCP).
[0060] Among them, the core consensus network 43 includes multiple consensus branch networks, such as blockchain network one 431, blockchain network two 432, and blockchain network three 433, etc. Each consensus branch network includes multiple consensus nodes (i.e., consensus node devices). Multiple consensus nodes in each consensus branch network maintain the blockchain corresponding to this consensus branch network. For example, the multiple consensus nodes included in blockchain network one 431 are used to maintain blockchain one corresponding to blockchain network one 431. Among them, different blockchains in the core consensus network 43 have different functions. For example, some blockchains are used to record transaction information of smart contracts, and some blockchains are used to record contract code information of smart contracts. When it is necessary to record data related to smart contracts, the blockchain to be recorded can be determined according to the permissions of business nodes, and then the consensus branch network that maintains this blockchain is used to record. Consensus nodes are usually computer devices used by management agencies in various regions. The consensus nodes in each consensus branch network include permission contracts, and the permission contracts store relevant data about smart contracts, etc. The consensus nodes also include caches and data blocks, and these functions can support the uploading and querying of transaction information to the blockchain.
[0061] It should be noted that all node devices in the blockchain network involved in the embodiments of the present application can be mobile phones, tablet computers, laptop computers, palm computers, mobile internet devices (MIDs), vehicles, roadside devices, aircraft, wearable devices, such as smart watches, smart bracelets, pedometers, etc., which are intelligent devices with data processing functions. The device types corresponding to each node device can be the same or different.
[0062] As Figure 5 shown, Figure 5 is an application schematic diagram of the blockchain network layering provided by the embodiments of the present application. As Figure 5 shown, the core consensus network runs the main chain, which is the overall main chain service. Each institution (the institutions to which the smart contract belongs can be divided to obtain different levels of institutions, such as first-level institutions and second-level institutions) synchronously associates relevant business data visible to the institutions (such as peer institutions) in the form of the institutional main chain SPV. The corresponding main chain business transactions are also forwarded to the core network entrance through the institutional main chain SPV and finally sent to the consensus network for consensus execution. Among them, SPV refers to Simplified Payment Verification, that is, a lightweight node that only needs to save the block header and can find matching transactions in the blockchain. As Figure 5 shown, there are 2 institutional main chain SPVs, indicating service dual-active. Their roles, data, and permissions are exactly the same. Of course, there can also be more than 2. The present application does not limit the number of institutional main chain SPVs.
[0063] In the institutional sector, a local consensus network is independently operated. The nodes in it are institutional SPV + local consensus nodes. These nodes not only synchronize the main chain data from the institutional main chain SPV, but also form a local consensus network among themselves, accept transactions, and conduct local block packaging and consensus. All transactions sent to the local consensus will not be forwarded to the main chain, but the business processing of the local chain will be completed in the local institution. If necessary, the summary information in the local consensus can be uploaded to the main chain. Outside the local consensus network are the next-level SPV and business SPV nodes (such as Business SPV Node 1, Business SPV Node 2, Business SPV Node 3, and Business SPV Node 4). These nodes no longer synchronize the ledger of the main chain, but can obtain the main chain business information related to the business from the local consensus network. At the same time, they synchronize the ledger data of the local consensus and obtain their own relevant ledger and status data in the same way as the security SPV data clearing. Their own business transactions are also sent to the local consensus network. In this way, by setting up the local consensus network and the core network, the confidentiality and security of the data on the blockchain can be improved, as well as the data processing efficiency.
[0064] In this application, it can be distinguished based on the contract institution to which the smart contract belongs (or the institution that uploads the smart contract to the chain), and a local consensus network corresponding to different contract institutions is formed. The nodes in the local consensus network corresponding to different contract institutions are institutional SPV + local consensus nodes. These nodes not only synchronize the main chain data from the institutional main chain SPV, but also form a local consensus network among themselves, accept transactions, and conduct local block packaging and consensus. All transactions sent to the local consensus will not be forwarded to the main chain, but the business processing of the local chain will be completed in the contract institution. If necessary, the summary information in the local consensus can be uploaded to the main chain. For example, when the institution to which the smart contract belongs is a first-level institution, a local consensus network corresponding to the first-level institution can be formed. The local consensus network corresponding to the first-level institution is used to conduct local packaging and block consensus for the transactions associated with the smart contracts belonging to the first-level institution. The transactions of the local consensus will not be forwarded to the main chain, but the business processing of the local chain will be completed in the contract institution. If necessary, the summary information in the local consensus can be uploaded to the main chain. In this way, by setting up the local consensus network and the core network, the confidentiality and security of the data on the blockchain can be improved, as well as the data processing efficiency. Of course, it can also be distinguished based on the region to which the institution that uploads the smart contract belongs, and a local consensus network corresponding to different contract upload regions is formed. The nodes in the local consensus network corresponding to different contract upload regions are institutional SPV + local consensus nodes. These nodes not only synchronize the main chain data from the institutional main chain SPV, but also form a local consensus network among themselves, accept transactions, and conduct local block packaging and consensus.
[0065] For ease of understanding, further, please refer toFigure 6 , Figure 6 is a schematic diagram of a scenario for automatically updating an original smart contract provided by an embodiment of the present application. As Figure 6 shown, the terminal device 60a can be a terminal device held by the service object 60b. The terminal device 60a can be Figure 2 any terminal device in the terminal device cluster 1Y in Figure 2 , such as the terminal device 100b in Figure 3 . The service node 60e can be a service node in the service network of the blockchain network 1X in the above Figure 6 , such as the node 200a in the service network. Specifically, a smart contract update client can be installed in the terminal device 60a. The smart contract update client provides a contract update interface 60c, and the contract update interface 60c is used for the service object 60b to submit an updated smart contract for contract update. As
[0066] The terminal device 60a can obtain the contract identification to be updated input by the service object 60b, obtain the smart contract corresponding to the contract identification to be updated from the blockchain network as the original smart contract, and obtain the contract code information input by the service object 60b. Then, it determines the initial smart contract according to the contract code information, and further determines the updated smart contract used to update the original smart contract according to the initial updated smart contract. The terminal device 60a can also obtain the object information input by the service object 60b as the object attribute information of the service object 60b, and then verify the update permission of the service object 60b for the original smart contract according to the object attribute information. In this way, the security of the original smart contract update can be ensured, and the original smart contract can be prevented from being tampered with. When it is determined that the service object 60b has the update permission for the original smart contract, the terminal device 60a can obtain the first contract attribute information of the original smart contract, and the first contract attribute information may include contract identification information, contract address information, contract update characteristics, contract data structure, etc. At the same time, the terminal device 60a can also obtain the second contract attribute information of the updated smart contract, and the second contract attribute information may also include contract identification information, contract address information, contract update characteristics, contract data structure, etc.
[0067] Specifically, the terminal device 60a can verify the update legality of the updated smart contract according to the first contract attribute information and the second contract attribute information. Only when the updated smart contract has update legality, a contract update request for instructing to update the original smart contract with the updated smart contract is generated. In this way, verifying the update legality of the updated smart contract can ensure the stability and reliability of the updated smart contract, and can avoid problems such as contract update failure or great losses to the contract calling object when the updated smart contract does not have update legality (such as the updated smart contract has code defects and cannot run, the updated smart contract has illegal attack codes, the updated smart contract has a large number of duplicate code steps to consume user transaction fees (i.e., transaction gas), etc.). Further, the terminal device 60a can send the contract update request to the signature object 60d associated with the original smart contract, and the signature object 60d may refer to the manager of the original smart contract. The signature object 60d can approve the contract update request. When the signature object 60d agrees to the contract update request, an update confirmation signature can be generated and returned to the terminal device 60a. It can be seen that approving the contract update request for the original smart contract by the signature object 60d can ensure the security and reliability of the original smart contract update.
[0068] Further, the terminal device 60a may receive an updated confirmation signature returned by the signature object 60d, and according to the received updated confirmation signature, send an updated smart contract for updating the original smart contract to the server 60e. The server 60e is the background server of the smart contract update client and is also a business node accessing the blockchain network 1X. The server 60e may upload the updated smart contract to the blockchain in the blockchain network. At the same time, determine a proxy smart contract corresponding to the original smart contract, where the proxy smart contract is used to call the original smart contract. It can be understood that when it is necessary to call the original smart contract to execute related services, the proxy smart contract is called, and the proxy smart contract calls the original smart contract to execute related services. The server 60e may call the proxy smart contract, update the original smart contract according to the updated smart contract, and return an update result to the terminal device 60a, that is, an update success or update failure result. It can be seen that this application can update the original smart contract according to the updated smart contract, and there is no need for the business object to write its own underlying proxy to implement the contract update of the original smart contract, which can improve the update efficiency of the original smart contract update. At the same time, the update legality of the updated smart contract is verified, and only when it is determined that the updated smart contract has update legality, a contract update request is initiated, which can avoid malicious attacks or tampering of the updated smart contract and ensure the stability and reliability of the original smart contract update. In addition, the signature object associated with the original smart contract approves the update of the original smart contract, further ensuring the security of the original smart contract update.
[0069] Further, please refer to Figure 7 , Figure 7 which is a schematic flowchart I of a blockchain-based data processing method provided by an embodiment of this application. As Figure 7 shown, this method may Figure 2 be executed by any one of the terminal devices in the terminal device cluster 1Y in Figure 2 , or may Figure 2 be executed by any one of the business nodes in the blockchain network 1X in Figure 2 , or may be jointly executed by any one of the terminal devices in the terminal device cluster 1Y in Figure 2 and any one of the business nodes in the blockchain network 1X. The devices used to execute this method in this application may be collectively referred to as computer devices. The blockchain-based data processing method may at least include but is not limited to the following steps:
[0070] S101, obtain first contract attribute information of an original smart contract to be updated in a block network, and second contract attribute information of an updated smart contract of the original smart contract.
[0071] Specifically, the computer device can obtain the first contract attribute information of the original smart contract to be updated in the blockchain network. The original smart contract can be the smart contract that the business object designates to be updated. The first contract attribute information can include contract identification information, contract data structure, contract update characteristics, contract address information, etc. At the same time, the updated smart contract used to update the original smart contract can be the smart contract uploaded by the business object. The second contract attribute information of the updated smart contract can also include contract identification information, contract data structure, contract update characteristics, contract address information, etc. Among them, the computer device can provide a contract update interface, and the business object can submit relevant information for updating the smart contract in the blockchain network through this contract update interface. The computer device can obtain information such as the original smart contract to be updated and the updated smart contract used to update the original smart contract through this contract update interface. In this way, the convenience and operability of smart contract updates can be improved.
[0072] Optionally, when a business object uploads a smart contract for updating an original smart contract, the computer device may determine the smart contract uploaded by the business object as the initial updated smart contract of the original smart contract to be updated. At the same time, the computer device may obtain the object attribute information of the business object, which may include the object name, object identifier, object contact information, etc. The computer device may verify the update permission of the business object for the original smart contract based on the object attribute information of the business object to obtain a permission verification result. The permission verification result may include a verification result indicating that the business object has the update permission for the original smart contract, or a verification result indicating that the business object does not have the update permission for the original smart contract. In this way, verifying the update permission of the business object can ensure the security of the original smart contract update and avoid the situation where the original smart contract is maliciously updated. If the permission verification result indicates that the business object has the finer update permission for the original smart contract, the source code file of the initial updated smart contract is compiled into bytecode to obtain an executable file of the initial updated smart contract. The executable file may refer to executable bytecode, that is, bytecode. Bytecode is a binary file containing an execution program and consisting of a sequence of code / data pairs. Since the machine does not understand the JAVA source code file written by the programmer, the JAVA source code file must be compiled into a class file to be recognized by the machine. The executable file is determined as the updated smart contract of the original smart contract. In this way, only when the business object has the update permission for the original smart contract, the source code file of the initial updated smart contract uploaded by the business object is compiled, which can save computing resources. At the same time, the computer device completes the compilation of the initial updated smart contract and the generation of the executable file, which can improve the acquisition efficiency of the updated smart contract and provide user convenience.
[0073] Optionally, the specific methods for the computer device to obtain the initial updated smart contract of the original smart contract to be updated uploaded by the business object and to obtain the object attribute information of the business object may include: displaying a contract update interface; the contract update interface includes a contract identifier editing area, a contract details editing area, and an object information editing area. In response to a first editing operation of the business object on the contract identifier editing area, the contract identifier input by the first editing operation is obtained, and the smart contract corresponding to the contract identifier to be updated is obtained from the blockchain network as the original smart contract to be updated. In response to a second editing operation of the business object on the contract details editing area, the contract code information input by the second editing operation is determined as the initial updated smart contract. In response to a third editing operation of the business object on the object information editing area, the object attribute information of the business object is determined according to the object information input by the third editing operation.
[0074] Specifically, the computer device can display a contract update interface, and the business object can directly input relevant information for updating the original smart contract in this contract update interface, which can improve the convenience and efficiency of updating the original smart contract. At the same time, it can also save the energy and time of the business object and provide a user experience. Among them, the contract update interface displays a contract identifier editing area, a contract details editing area, an object information editing area, etc. The contract identifier editing area is used to input the contract identifier of the original smart contract that needs to be updated. The contract details editing area is used to input the updated smart contract of the original smart contract to be updated. The object information editing area is used to input the object attribute information of the business object of the updated smart contract. Specifically, the business object can input the contract identifier of the original smart contract to be updated in the contract identifier editing area. The computer device can, in response to the first editing operation of the business object on the contract identifier editing area, obtain the contract identifier input by the first editing operation as the contract identifier to be updated, and according to this contract identifier to be updated, obtain the smart contract corresponding to the contract identifier to be updated from the blockchain network as the original smart contract to be updated. Of course, if there is no smart contract corresponding to the contract identifier to be updated in the blockchain network, an update error prompt message will be output, and this update error prompt message can be used to prompt that there is no smart contract corresponding to the contract identifier to be updated in the blockchain network. Or, the business object can select a candidate smart contract from multiple candidate smart contracts displayed in the contract identifier editing area. The computer device can, in response to the selection operation of the business object on the multiple candidate smart contracts displayed in the contract identifier editing area, determine the candidate smart contract determined by this selection operation as the original smart contract to be updated. In this way, the original smart contract to be updated can be quickly obtained.
[0075] Similarly, a business object can input the contract code information of the updated smart contract of the original smart contract in the contract details editing area, and can also input the contract ABI (i.e., contract binary interface), contract description information, contract explanation information, etc. The computer device can, in response to a second editing operation of the business object on the contract details editing area, determine the contract code information input by the second editing operation as the initial updated smart contract. In this way, the initial updated smart contract can be quickly obtained. Similarly, a business object can input the object name, object identifier, object contact information, etc. of the business object in the object information editing area. The computer device can, according to a third editing operation of the business object on the object information editing area, determine the object attribute information of the business object based on the object information input by the third editing operation. In this way, the update permission of the business object for the original smart contract can be verified through the object attribute information to ensure the security of the update of the original smart contract. At the same time, relevant information about the updated smart contract can be notified to the business object through the object contact information, providing a user experience. It can be seen that the embodiment of the present application provides a visual contract update interface for the business object, and can quickly and conveniently submit information such as the updated smart contract for updating the original smart contract and the object attribute information of the business object, realizing the automatic upgrade of the original smart contract, reducing the time and effort of the business object to manually write and deploy the updated smart contract, improving the update efficiency and security of the original smart contract, and also providing a user experience.
[0076] Optionally, the object attribute information of the business object includes the object identifier of the business object. The specific manner in which the computer device verifies the update permission of the business object for the original smart contract based on the object attribute information of the business object to obtain a permission verification result may include: obtaining the identification matching degrees between the object identifier of the business object and Q permission identifiers included in the permission identifier table; the permission identifier table includes the object identifiers of the permission objects having the update permission for the original smart contract; Q is a positive integer. If there is a permission identifier in the permission identifier table whose identification matching degree with the object identifier of the business object is greater than or equal to the matching degree threshold, it is determined that the business object has the update permission for the original smart contract, and a permission verification result for indicating that the business object has the update permission for the original smart contract is generated.
[0077] Specifically, the computer device obtains a permission identification table associated with the original smart contract. The permission identification table includes Q permission identifications, and the permission identification is the object identification of the permission object having the update permission for the original smart contract. In other words, the permission identification table includes the object identifications of the permission objects having the update permission for the original smart contract. Among them, the permission identification table can be stored in the blockchain network. In this way, it can be avoided that the permission identification table is illegally tampered with, and the accuracy of permission verification can be improved. If there is a permission identification in the permission identification table whose identification matching degree with the object identification of the business object is greater than or equal to the matching degree threshold, it is determined that the business object has the update permission for the original smart contract, and a permission verification result is generated to indicate that the business object has the update permission for the original smart contract. Among them, the matching degree threshold can be set according to user requirements. Of course, if there is no permission identification in the permission identification table whose identification matching degree with the object identification of the business object is greater than or equal to the matching degree threshold, it is determined that the business object does not have the update permission for the original smart contract, and a permission verification result is generated to indicate that the business object does not have the update permission for the original smart contract.
[0078] S102. Check the update legality of the updated smart contract according to the first contract attribute information and the second contract attribute information, and obtain a legality check result.
[0079] Specifically, the computer device can check the update legality of the updated smart contract according to the first contract attribute information and the second contract attribute information, and obtain a legality check result. The contract check result can be used to indicate that the updated smart contract has update legality, or to indicate that the updated smart contract does not have update legality. In this way, checking the update legality of the updated smart contract can ensure the stability and reliability of the updated smart contract, and can avoid problems such as low stability and reliability when the updated smart contract does not have update legality (such as the updated smart contract has code defects and cannot run, the updated smart contract has illegal attack code, the updated smart contract has a large number of repeated code steps to consume user transaction fees (i.e., transaction gas), etc.), resulting in contract update failure or causing great losses to contract call objects.
[0080] Optionally, the first contract attribute information includes the contract data structure of the original smart contract, and the second contract attribute information includes the contract data structure of the updated smart contract. The contract data structure includes one or more data storage fields (i.e., state variables) in the smart contract, such as a contract identification field, a contract log data field, and a contract call object field, etc. The contract data structure also includes the field values corresponding to one or more data storage fields (i.e., the data of the smart contract), that is, the contract data structure includes meaningful Key-Value pairs. Since the contract data structure of the smart contract cannot be changed after the smart contract is updated, just like the data in a mobile phone cannot be lost after the mobile phone terminal is upgraded. If the contract data structure changes, it means that the data in the contract data structure has changed, which is not allowed. Therefore, there needs to be compatibility between the updated smart contract and the original smart contract, that is, the contract data structure of the updated smart contract includes the contract data structure of the original smart contract, that is, the contract data structure of the original smart contract has not been deleted, and only then is it allowed to use the updated smart contract to update the original smart contract.
[0081] Optionally, the computer device checks the update legality of the updated smart contract according to the first contract attribute information and the second contract attribute information. The specific method for obtaining the legality check result may include: The computer device checks the compatibility between the original smart contract and the updated smart contract according to the contract data structure of the original smart contract and the contract data structure of the updated smart contract, and obtains a compatibility check result. If the compatibility check result indicates that there is compatibility between the original smart contract and the updated smart contract, it is determined that the updated smart contract has update legality, and a legality check result for indicating that the updated smart contract has update legality is generated. In this way, it can be ensured that the update of the original smart contract is successful, avoiding the situation where the updated smart contract and the original smart contract are not compatible, resulting in the failure of the contract update, reducing resource waste, and improving the efficiency of updating the original smart contract.
[0082] Optionally, the specific method for the computer device to verify the compatibility between the original smart contract and the updated smart contract according to the contract data structure of the original smart contract and the contract data structure of the updated smart contract may include: obtaining M original storage fields in the contract data structure of the original smart contract, and obtaining S updated storage fields in the contract data structure of the updated smart contract; M is a positive integer, and S is a positive integer greater than or equal to M. Determine M pairs of storage fields from the S updated storage fields and the M original storage fields; each pair of storage fields includes one updated storage field and one original storage field; the position of the updated storage field in the updated smart contract in each pair of storage fields is the same as the position of the corresponding original storage field in the original smart contract. When the data type of the updated storage field in each pair of storage fields among the M pairs of storage fields is the same as the data type of the corresponding original storage field, it is determined that there is compatibility between the original smart contract and the updated smart contract, and a compatibility verification result is generated to indicate the compatibility between the original smart contract and the updated smart contract.
[0083] Specifically, the computer device may obtain the data storage fields in the contract data structure of the original smart contract to obtain M original storage fields, and obtain the data storage fields in the contract data structure of the updated smart contract to obtain S updated storage fields. The computer device may determine M pairs of storage fields from the S updated storage fields and the M original storage fields. Each pair of storage fields includes one updated storage field and one original storage field. The position of the updated storage field in the updated smart contract in each pair of storage fields is the same as the position of the corresponding original storage field in the original smart contract. For example, the position of the updated storage field in the first pair of storage fields among the M pairs of storage fields in the updated smart contract is the first in the arrangement, and the position of the original storage field in the first pair of storage fields in the original smart contract is also the first in the arrangement. The position of the updated storage field in the second pair of storage fields among the M pairs of storage fields in the updated smart contract is the second in the arrangement, and the position of the original storage field in the second pair of storage fields in the original smart contract is also the second in the arrangement.
[0084] Of course, if M storage field pairs cannot be determined from the S updated storage fields and M original storage fields, for example, if the number of S updated storage fields is less than the number of M original storage fields, it indicates that the fields in the M original storage fields have been deleted, and it is determined that there is no compatibility between the original smart contract and the updated smart contract. Further, the computer device can detect whether the data type of the updated storage field in each storage field pair among the M storage field pairs is the same as the data type of the original storage field in the corresponding storage field pair. When the data type of the updated storage field in each storage field pair among the M storage field pairs is the same as the data type of the original storage field in the corresponding storage field pair, it is determined that there is compatibility between the original smart contract and the updated smart contract, and a compatibility verification result indicating that there is compatibility between the original smart contract and the updated smart contract is generated. Of course, when the data type of the updated storage field in each storage field pair among the M storage field pairs is different from the data type of the original storage field in the corresponding storage field pair, it indicates that the data structure in the original smart contract has been modified, and it is determined that there is no compatibility between the original smart contract and the updated smart contract.
[0085] Optionally, the first contract attribute information includes the contract identification information of the original smart contract, and the second contract attribute information includes the contract code information of the updated smart contract. The specific manner in which the computer device verifies the update legality of the updated smart contract based on the first contract attribute information and the second contract attribute information to obtain a legality verification result may include: querying the contract log data of the original smart contract from the blockchain network according to the contract identification information of the original smart contract. Detecting the contract update characteristics of the original smart contract based on the contract log data. If the contract update characteristics indicate that the original smart contract is updatable, then detecting the security of the updated smart contract according to the contract code information of the updated smart contract to obtain a security detection result. If the security detection result indicates that the security of the updated smart contract is greater than or equal to the security threshold, it is determined that the updated smart contract has update contractability, and a legality verification result indicating that the updated smart contract has update legality is generated.
[0086] Specifically, the computer device can query the contract log data of the original smart contract from the blockchain network according to the contract identification information of the original smart contract, and detect the contract update characteristics of the original smart contract according to the contract log data. Of course, the computer device can also obtain the contract update characteristics table from the blockchain network, and query the contract update characteristics of the original smart contract from the contract update characteristics table according to the contract identification information of the original smart contract. The contract update characteristics table is stored in the blockchain network, which can avoid being tampered with and ensure the security of the contract update characteristics table. The contract update characteristics table includes the contract update characteristics of the smart contracts in the blockchain network, and the contract update characteristics are used to reflect whether the smart contract can be updated. In this way, it can avoid the situation where the contract fails and then wastes computing resources when the original smart contract cannot be updated.
[0087] Further, if the computer device determines that the contract update characteristics of the original smart contract reflect that the original smart contract has updatability, it detects the security of the updated smart contract according to the contract code information of the updated smart contract, and obtains the security detection result. If the security detection result indicates that the security of the updated smart contract is greater than or equal to the security threshold, it determines that the updated smart contract has update contractability, and generates a legality verification result for indicating that the updated smart contract has update legality. In this way, the security and reliability of the update of the original smart contract can be ensured.
[0088] Optionally, the specific method for the computer device to detect the contract update characteristics of the original smart contract according to the contract log data may include: determining the call object of the original smart contract according to the contract log data. If the call object is a proxy smart contract and the contract data structure of the original smart contract is stored in the proxy smart contract, it is determined that the original smart contract has updatability, and a contract update characteristic for reflecting that the original smart contract has updatability is generated.
[0089] Specifically, the computer device can determine the calling object of the original smart contract based on the contract log data of the original smart contract, that is, determine who called the original smart contract according to the contract log data. If the calling object of the original smart contract is the proxy smart contract and the contract data structure of the original smart contract is stored in the proxy smart contract, it is determined that the original smart contract has the characteristics of being updatable. It can be understood that when the smart contract is deployed in the blockchain network, its running logic cannot be modified. Therefore, it can be replaced but not modified. An updated smart contract can be newly deployed to replace the original smart contract. If there is a proxy smart contract for the original smart contract, other calling objects only need to call the proxy smart contract according to the contract address of the proxy smart contract, and the proxy smart contract calls the original smart contract. In this way, when the original smart contract is updated, only the calling address of the proxy smart contract needs to be changed, and other calling objects do not need to change the calling address, which can greatly reduce the workload caused by modifying the calling address and improve the efficiency of updating the original smart contract. At the same time, since the contract update is to update the contract running logic and the contract data state will not change, when the contract data structure of the original smart contract is stored in the proxy smart contract, it means that the original smart contract can be updated.
[0090] Optionally, the computer device detects the security of the updated smart contract according to the contract code information of the updated smart contract. The specific method for obtaining the security detection result may include: pre-executing the updated smart contract to obtain a pre-execution result. If the pre-execution result reflects that the contract code of the updated smart contract is executable, the contract security detection model is called to detect the security of the updated smart contract to obtain the security detection result of the updated smart contract.
[0091] Specifically, the computer device can pre-execute the contract code of the updated smart contract to obtain a pre-execution result. This pre-execution result can be used to reflect whether the updated smart contract can be executed, that is, whether the updated smart contract is executable. In this way, it can avoid the problem that the updated original smart contract cannot be executed after using the updated smart contract to update the original smart contract, and ensure the stability and reliability of the updated smart contract. If the pre-execution result reflects that the updated smart contract is executable, the contract security detection model is called to verify the security of the updated smart contract to obtain the security verification result of the updated smart contract. Among them, the contract security detection model can be trained by sample training data (contract code of the smart contract) and security labels.
[0092] The contract security detection model can detect the contract code of the updated smart contract, such as detecting whether there are code defect problems in the contract operation logic of the updated smart contract, detecting whether there are operation failure problems in the contract operation logic of the updated smart contract, detecting whether there are code reentry problems in the contract operation logic of the updated smart contract, detecting whether there are integer overflow problems in the contract operation logic of the updated smart contract, detecting whether there is a failure to strictly judge the return value of an insecure function call, and one or more of other unknown vulnerabilities. For example, if the contract security detection model detects one or more problems such as code defect problems, operation failure problems, code reentry problems, integer overflow problems, or failure to strictly judge the return value of an insecure function call in the contract operation logic of the updated smart contract, it outputs the contract security of the updated smart contract. In this way, by predicting the security of the updated smart contract through the contract security detection model, the accuracy and efficiency of the security detection of the updated smart contract can be improved.
[0093] Of course, the computer device can also perform contract initialization detection. When updating the original smart contract, since the contract data structure of the original smart contract is stored in the proxy smart contract, it is necessary to check the contract data state of the proxy smart contract to check whether the contract data state in the proxy smart contract has been initialized. In this way, the accuracy of the contract data stored in the proxy smart contract can be ensured. It can be understood that when using the updated smart contract to update the original smart contract, the computer device can perform an update check on the updated smart contract. The update check can include one or more of the following checks: storage space layout compatibility validity (i.e., detecting the compatibility between the original smart contract and the updated smart contract), whether the original smart contract has the characteristics of being updatable, updated smart contract security check, contract initialization detection, etc. By performing an update check on the updated smart contract, the compatibility and legality of the updated smart contract can be ensured, thereby improving the stability and reliability of the updated smart contract.
[0094] S103, if the legality verification result indicates that the updated smart contract has update legality, then generate a contract update request for indicating to update the original smart contract with the updated smart contract, and send the contract update request to the signature object associated with the original smart contract; the signature object is used to generate an update confirmation signature according to the contract update request.
[0095] Specifically, if the legality verification result indicates that the updated smart contract has update legality, a contract update request for indicating to update the original smart contract with the updated smart contract is generated. The contract update request may include second contract attribute information of the updated smart contract, and the second contract attribute information may include one or more of a contract version number, contract code, contract description information, contract specification information, update legality detection result, etc. Of course, the contract update request may also include object attribute information of a business object, first contract attribute information of the original smart contract, etc. The first contract attribute information may include a contract version number, contract identification information, contract name, etc. The computer device may send the contract update request to a signature object associated with the original smart contract. The signature object may refer to a manager of the original smart contract, a creation object of the original smart contract, or an object designated by the manager or creation object of the original smart contract, etc. The signature object may approve the contract update request. When the contract update request is approved (i.e., when the signature object agrees to the contract update request), the contract update request may be signed to obtain an update confirmation signature, and the update confirmation signature is returned to the computer device.
[0096] Optionally, the contract update request may refer to a multi-signature update interface. If the legality verification result indicates that the updated smart contract has update legality, the computer device may automatically open a multi-signature update interface for indicating to update the original smart contract with the updated smart contract, and send the multi-signature update interface to a signature object associated with the original smart contract. The first contract attribute information of the updated smart contract, the second contract attribute information of the original smart contract, and the object attribute information of the business object, etc. are displayed in the multi-signature update interface. The signature object may approve the update of the original smart contract according to the information displayed in the multi-signature update interface. If the signature object agrees to update the original smart contract, the confirmation control is clicked in the multi-signature update interface to return an update confirmation signature to the computer device. If the signature object agrees to update the original smart contract, the rejection control is clicked in the multi-signature update interface, and the update confirmation signature is not returned to the computer device. Specifically, when the signature object clicks the confirmation control in the multi-signature update interface, the terminal device of the signature object may sign the multi-signature update interface (or specified data) with the object private key of the signature object to obtain an update confirmation signature.
[0097] S104, receive the update confirmation signature returned by the signature object, and according to the received update confirmation signature, upload the updated smart contract to the blockchain of the blockchain network.
[0098] Specifically, the computer device can receive the updated confirmation signature returned by the signature object. According to the received updated confirmation signature, it can detect whether the original smart contract can be updated using the updated smart contract. The computer device can perform a validity check on the received updated confirmation signature, so as to avoid the situation where the updated confirmation signature is sent by an illegal object. At the same time, the computer device can count the number of valid signatures in the received updated confirmation signatures. If the number of signatures is greater than or equal to the verification threshold value, it is determined that the original smart contract can be updated using the updated smart contract. When it is determined that the original smart contract can be updated using the updated smart contract, the computer device can upload the updated smart contract to the blockchain of the blockchain network. In this way, the security and reliability of the update of the original smart contract can be improved.
[0099] S105, call the proxy smart contract corresponding to the original smart contract, and update the original smart contract according to the updated smart contract.
[0100] Specifically, the computer device can call the proxy smart contract corresponding to the original smart contract. Since this proxy smart contract is used to call the original smart contract, the original smart contract can be updated according to the updated smart contract, and the proxy smart contract can be adjusted to change from calling the original smart contract to calling the updated smart contract. To achieve the update of the original smart contract. In this way, other calling objects can directly call the updated original smart contract (i.e., the updated smart contract) through the proxy smart contract. Since the contract address of the proxy smart contract has not changed, other calling objects do not need to make any code modifications, which can reduce the modification workload and improve the efficiency of the update of the original smart contract. It can be seen that the embodiments of the present application provide a pipeline service for automatic update of smart contracts. Business objects can submit the updated smart contract and related information for updating the original smart contract in a visual contract update interface, which can improve the acquisition efficiency of the updated smart contract and save the time and energy of business objects at the same time. At the same time, the present application can automatically compile the updated smart contract and generate executable bytecode, and at the same time perform an update legality check on the updated smart contract to ensure the compatibility and effectiveness between the updated smart contract and the original smart contract, which can improve the stability and reliability of the updated smart contract. At the same time, the signature object approval process can be automatically started, and the signature object can approve the update of the original smart contract, which can prevent problems such as malicious tampering of the original smart contract or malicious attack code stored in the updated smart contract, and can improve the security of the update of the original smart contract.
[0101] Optionally, the computer device invokes the proxy smart contract corresponding to the original smart contract. The specific method for updating the original smart contract according to the updated smart contract may include: invoking the proxy smart contract corresponding to the original smart contract to obtain the updated contract address of the updated smart contract on the blockchain. Updating the original contract address in the proxy smart contract according to the updated contract address; the original contract address is the address of the original smart contract on the blockchain. Updating the original storage field in the proxy smart contract according to the updated storage field in the contract data structure of the updated smart contract; the original storage field belongs to the data in the contract data structure of the original smart contract.
[0102] Specifically, the computer device can determine the proxy smart contract for invoking the original smart contract from the blockchain network according to the contract identification information of the original smart contract. Since the updated smart contract has been uploaded to the blockchain in the blockchain network. Therefore, the computer device can invoke the proxy smart contract to obtain the contract address of the updated smart contract on the blockchain as the updated contract address of the updated smart contract. The computer device can update the original contract address in the proxy smart contract according to the updated smart contract address, and the original contract address is the address of the original smart contract on the blockchain. Among them, it can be understood that the process of changing the original contract address in the proxy smart contract to the updated contract address can be executed in the TEE (Trusted Execution Environment). Among them, the trusted execution environment is a hardware-based privacy computing solution. A secure area is built in the CPU (Central Processing Unit) through software and hardware methods to ensure the confidentiality and integrity of the programs and data loaded inside. The TEE divides the system's hardware resources and software resources into two execution environments - the trusted part and the untrusted part (ordinary part). These two environments are isolated, and the untrusted part cannot access the storage and memory of the trusted part. After updating the original contract address in the proxy smart contract according to the updated smart contract address, the call of the proxy smart contract is redirected from the original smart contract to the updated smart contract, thus realizing the update of the original smart contract. Since the proxy smart contract is used to store the contract data structure of the called original smart contract, when the call of the proxy smart contract is redirected to the updated smart contract, it is necessary to update the original storage field in the proxy smart contract according to the updated storage field in the contract data structure of the updated smart contract, and the original storage field belongs to the data in the contract data structure of the original smart contract. In this way, the accuracy of the contract update can be ensured, and the contract data of the updated smart contract can be ensured to be stored in the proxy smart contract, avoiding the loss of the contract data of the updated smart contract.
[0103] Specifically, when updating the original storage fields in the proxy smart contract according to the updated storage fields in the contract data structure of the updated smart contract, the computer device can obtain the storage fields in the updated storage fields of the contract data structure of the updated smart contract that are different from the original storage fields in the contract data structure of the original smart contract as the differential storage fields. That is, the differential storage fields are the newly added storage fields in the updated smart contract. The computer device can add the above differential storage fields after the original storage fields at the last position in the contract data structure of the original smart contract stored in the proxy smart contract, and at the same time set the field value of the differential storage fields to the initialization field value, that is, backward compatibility adaptation. In this way, the availability of the updated smart contract can be ensured, as well as the stability and reliability of the updated smart contract.
[0104] Optionally, the specific method for the computer device to update the original contract address in the proxy smart contract according to the updated contract address may include: generating an address change transaction for instructing to change the original contract address in the proxy smart contract to the updated contract address. Sending the address change transaction to the consensus nodes in the blockchain network; the consensus nodes are used to perform consensus on the address change transaction to obtain a change consensus result. Receiving the change consensus result returned by the consensus nodes, and if the change consensus result indicates that the consensus nodes have successfully consensus on the address change transaction, changing the original contract address in the proxy smart contract to the updated contract address.
[0105] Specifically, the computer device can generate an address change transaction for instructing to change the original contract address in the proxy smart contract to the updated contract address, and send the address change transaction to the consensus nodes in the blockchain network. The consensus nodes are used to perform consensus on the address change transaction to obtain a change consensus result. In this way, having the consensus nodes perform consensus on the address change transaction can ensure the security of changing the original contract address in the proxy smart contract and avoid illegal tampering of the original smart contract. The computer device can receive the change consensus result returned by the consensus nodes. If the change consensus result indicates that the consensus nodes have successfully consensus on the address change transaction, the computer device can call the proxy smart contract to change the original contract address in the proxy smart contract to the updated contract address to implement the update of the original smart contract. In this way, the security of updating the original smart contract can be improved. At the same time, the computer device can upload the address change transaction to the blockchain, which can ensure the traceability of the update record of the original smart contract. At the same time, the computer device can display the update result of updating the original smart contract with the updated smart contract to the business object, that is, the update is successful or failed. At the same time, the computer device can also notify the signature object, the creation object of the original smart contract, the management object, etc. of the update result.
[0106] In an embodiment of the present application, a pipeline service for automatically updating smart contracts is provided, which can ensure the security of the update of the original smart contract while realizing the automatic update of the original smart contract. Specifically, by using the first contract attribute information of the original smart contract and the second contract attribute information of the updated smart contract, the update legality of the updated smart contract is verified, which can avoid the situation that the updated smart contract contains malicious attack code or the updated smart contract is incompatible with the original smart contract, resulting in update failure, and can ensure the stability and reliability of the update of the original smart contract. When the updated smart contract has update legality, a contract update request for instructing to update the original smart contract with the updated smart contract is sent to a signature object associated with the original smart contract, and an update confirmation signature returned by the signature object is received. According to the received update confirmation signature, the updated smart contract is uploaded to the blockchain of the blockchain network. It can be seen that the approval of the contract update request by the signature object can further improve the security and reliability of the update of the original smart contract and avoid the update of the original smart contract by illegal objects. The proxy smart contract corresponding to the original smart contract is called, and the original smart contract is updated according to the updated smart contract. It can be seen that the pipeline service for automatically updating smart contracts provided by the embodiment of the present application can realize the automatic update of smart contracts. Business objects do not need to write underlying code for each smart contract to implement the contract update of the smart contract, which saves time and effort, improves the efficiency of smart contract update, and can improve the stability and reliability of the updated smart contract, thereby improving the security of the update of the original smart contract.
[0107] Further, please refer to Figure 8 , Figure 8 which is a schematic flowchart 1 of a data processing method based on a blockchain provided by an embodiment of the present application. As Figure 8 shown, this method can Figure 2 be executed by any one of the terminal device clusters 1Y in Figure 2 , or can Figure 2 be executed by any one of the service nodes in the blockchain network 1X in Figure 2 , or can be jointly executed by any one of the terminal device clusters 1Y in Figure 2 and any one of the service nodes in the blockchain network 1X in Figure 2 . In the present application, the devices used to execute this method can be collectively referred to as computer devices. The data processing method based on a blockchain can at least include but is not limited to the following steps:
[0108] S201, Obtain the first contract attribute information of the original smart contract to be updated in the blockchain network, and the second contract attribute information of the updated smart contract of the original smart contract.
[0109] S202. Verify the update legality of the updated smart contract based on the first contract attribute information and the second contract attribute information to obtain a legality verification result.
[0110] S203. If the legality verification result indicates that the updated smart contract has update legality, generate a contract update request for indicating to update the original smart contract with the updated smart contract, and send the contract update request to the signature object associated with the original smart contract.
[0111] Specifically, for the content of steps S201 - S203 in the embodiments of this application, reference can be made to the content of steps S101 - S103 above, and the embodiments of this application will not elaborate here.
[0112] S204. Receive the update confirmation signature returned by the signature object, and verify the validity of the received update confirmation signature.
[0113] Specifically, the computer device can receive the update confirmation signature returned by the signature object. This update confirmation signature can be obtained by signing the contract update request with the object private key of the signature object. The signature algorithm for signing the contract update request can include any one of the BLS (Boneh - Lynn - Shacham Signature) signature algorithm, RSA signature algorithm, ECDSA (Elliptic Curve Digital Signature Algorithm) signature algorithm, Schnorr (a knowledge proof mechanism based on the discrete logarithm problem) signature algorithm, etc. Among them, the BLS signature algorithm is an encryption algorithm based on elliptic curves, and the length of the BLS signature algorithm is shorter (the signature is a point on the elliptic curve rather than two). The RSA signature algorithm is a classic asymmetric encryption algorithm. Different from symmetric encryption algorithms, the RSA signature algorithm has two different keys, one is the public key and the other is the private key. The ECDSA signature algorithm is an asymmetric encryption algorithm based on the mathematical theory of elliptic curves. Among them, in the ECDSA and Schnorr signature algorithms, after performing a hash calculation on the message to be signed, the result (hash value) is a number. The BLS signature algorithm uses the hash value obtained from the transaction data as the x - value of the point to find the corresponding point on the elliptic curve, and further signs the found point with the private key. The BLS signature algorithm does not require a random number generator, can aggregate all the signatures in a block into one, is easy to implement multi - signature, and can also avoid redundant communication between signers. In addition, the length of the BLS signature is shorter (the signature is a point on the elliptic curve rather than two), which is half of Schnorr or ECDSA.
[0114] Optionally, since the signature complexity and security of different signature algorithms are different, such as the more complex the signature algorithm, the higher the corresponding security. Therefore, the signature algorithm for signing the contract update request can be determined according to the importance of the original smart contract, which can improve the security of the update confirmation signature.
[0115] Specifically, the computer device verifies the validity of the received update confirmation signature according to the signature algorithm for signing the contract update request. For example, when the signature algorithm for signing the contract update request is the RSA signature algorithm, the update confirmation signature is obtained by signing the digest information of the contract update request with the object private key of the signature object. Therefore, the computer device can perform a hash operation on the contract update request to obtain the digest information of the contract update request, and at the same time use the object public key of the signature object to verify the update confirmation signature to obtain the digest information to be verified. If the digest information of the contract update request is the same as the digest information to be verified, it is determined that the update confirmation signature is valid. Of course, if the digest information of the contract update request is different from the digest information to be verified, it is determined that the update confirmation signature is not valid.
[0116] S205, count the number of valid update confirmation signatures among the received update confirmation signatures.
[0117] Specifically, after the computer device receives the update confirmation signature for validity verification, since the number of received update confirmation signatures can be one or more, the computer device can count the number of valid update confirmation signatures among the received update confirmation signatures. It can be understood that in this application, the signature object is used to confirm the executability of the contract update request. In this way, only after one or more signature objects approve the contract update request, the contract update request is executed, which can ensure the security of the original smart contract update.
[0118] S206, if the signature count is greater than or equal to the verification threshold, generate a contract on-chain transaction for updating the smart contract, and send the contract on-chain transaction to the consensus nodes in the blockchain network.
[0119] Specifically, the computer device can detect whether the number of signatures is greater than or equal to the verification threshold. If the number of signatures is less than the verification threshold, it is determined that the contract update request to update the original smart contract using the updated smart contract cannot be executed. If the number of signatures is greater than or equal to the verification threshold, a confirmation update interface for updating the original smart contract using the updated smart contract can be displayed for confirmation by the business object. If a confirmation operation from the business object is received, it is determined that the contract update request to update the original smart contract using the updated smart contract can be executed, a contract on-chain transaction for the updated smart contract is generated, and the contract on-chain transaction is sent to the consensus nodes in the blockchain network. The consensus nodes are used to conduct consensus on the contract on-chain transaction to obtain an on-chain consensus result. In this way, the security of the update of the original smart contract can be ensured. For example, the number of signature objects is 5, and the verification threshold is 3. If 4 update confirmation signatures returned by 4 signature objects are received, one update confirmation signature is returned by one signature object, and the 4 update confirmation signatures returned by the 4 signature objects are all valid, that is, 4 is greater than the verification threshold 3, then a contract on-chain transaction for the updated smart contract is generated.
[0120] S207. Receive the on-chain consensus result returned by the consensus node. If the on-chain consensus result indicates that the consensus node has successfully reached a consensus on the contract on-chain transaction, then upload the updated smart contract to the blockchain of the blockchain network.
[0121] Specifically, the computer device can receive the on-chain consensus result returned by the consensus node. If the on-chain consensus result indicates that the consensus node has successfully reached a consensus on the contract on-chain transaction, then upload the updated smart contract to the blockchain of the blockchain network. In this way, having the consensus node conduct consensus on the contract on-chain transaction can ensure the security of uploading the updated smart contract to the blockchain of the blockchain network and avoid uploading an illegal updated smart contract to the blockchain. Of course, if the on-chain consensus result indicates that the consensus node has successfully reached a consensus on the contract on-chain transaction, then upload the updated smart contract to the blockchain of the blockchain network. Of course, the computer device can upload the contract on-chain transaction to the blockchain to ensure the traceability of the on-chain record of the updated smart contract.
[0122] S208. Invoke the proxy smart contract corresponding to the original smart contract and update the original smart contract according to the updated smart contract.
[0123] Specifically, for the content of step S208 in the embodiments of the present application, reference can be made to the content of the above step S105, and details will not be elaborated herein in the embodiments of the present application.
[0124] In an embodiment of the present application, a pipeline service for automatic update of smart contracts is provided. While realizing the automatic update of the original smart contract, it can also ensure the security of the update of the original smart contract. Specifically, by using the first contract attribute information of the original smart contract and the second contract attribute information of the updated smart contract, the update legality of the updated smart contract is verified, which can avoid the situation that the updated smart contract contains malicious attack code or the updated smart contract is incompatible with the original smart contract, resulting in update failure, and can ensure the stability and reliability of the update of the original smart contract. When the updated smart contract has update legality, a contract update request for instructing to update the original smart contract with the updated smart contract is sent to a signature object associated with the original smart contract, and the update confirmation signature returned by the signature object is received. When the number of valid update confirmation signatures in the received update confirmation signatures is greater than or equal to the verification threshold value, the updated smart contract is uploaded to the blockchain of the blockchain network, which can ensure the security of the update of the original smart contract. It can be seen that having the signature object approve the contract update request can further improve the security and reliability of the update of the original smart contract and prevent illegal objects from updating the original smart contract. The proxy smart contract corresponding to the original smart contract is called, and the original smart contract is updated according to the updated smart contract. It can be seen that the pipeline service for automatic update of smart contracts provided by the embodiment of the present application can realize the automatic update of smart contracts. Business objects do not need to write underlying code for each smart contract to implement the contract update of the smart contract, saving time and effort, improving the efficiency of smart contract update, and at the same time can improve the stability and reliability of the updated smart contract, thereby improving the security of the update of the original smart contract.
[0125] Further, please refer to Figure 9 , Figure 9 which is a schematic structural diagram of a blockchain-based data processing device provided by an embodiment of the present application. The blockchain-based data processing device may be a computer program (including program code) running in a computer device. For example, the blockchain-based data processing device is an application software; the blockchain-based data processing device can be used to execute the corresponding steps in the method provided by the embodiment of the present application. As Figure 9 shown, the blockchain-based data processing device can be any terminal device in the terminal device cluster. The blockchain-based data processing device may include: a first acquisition module 11, a verification module 12, a sending module 13, a blockchain uploading module 14, an update module 15, a second acquisition module 16, a permission verification module 17, a compilation module 18, and a determination module 19.
[0126] The first acquisition module 11 is configured to acquire first contract attribute information of an original smart contract to be updated in a blockchain network, and second contract attribute information of an updated smart contract of the original smart contract;
[0127] The verification module 12 is configured to verify the update legality of the updated smart contract according to the first contract attribute information and the second contract attribute information, so as to obtain a legality verification result;
[0128] The sending module 13 is configured to, if the legality verification result indicates that the updated smart contract has update legality, generate a contract update request for instructing to update the original smart contract with the updated smart contract, and send the contract update request to a signature object associated with the original smart contract; the signature object is configured to generate an update confirmation signature according to the contract update request;
[0129] The on-chain module 14 is configured to receive the update confirmation signature returned by the signature object, and on-chain the updated smart contract to the blockchain in the blockchain network according to the received update confirmation signature;
[0130] The update module 15 is configured to call a proxy smart contract corresponding to the original smart contract, and update the original smart contract according to the updated smart contract.
[0131] Wherein, the update module 15 includes:
[0132] The first acquisition unit 1501 is configured to call a proxy smart contract corresponding to the original smart contract, and acquire an updated contract address of the updated smart contract on the blockchain;
[0133] The address update unit 1502 is configured to update the original contract address in the proxy smart contract according to the updated contract address; the original contract address is the address of the original smart contract on the blockchain;
[0134] The field update unit 1503 is configured to update the original storage field in the proxy smart contract according to the updated storage field in the contract data structure of the updated smart contract; the original storage field belongs to the data in the contract data structure of the original smart contract.
[0135] Wherein, the address update unit 1502 is specifically configured to:
[0136] Generate an address change transaction for instructing to change the original contract address in the proxy smart contract to the updated contract address;
[0137] Send the address change transaction to a consensus node in the blockchain network; the consensus node is configured to perform consensus on the address change transaction to obtain a change consensus result;
[0138] Receive the changed consensus result returned by the consensus node. If the changed consensus result indicates that the consensus node has successfully reached a consensus on the address change transaction, change the original contract address in the proxy smart contract to the updated contract address.
[0139] Among them, the blockchain-based data processing device further includes:
[0140] A second acquisition module 16, configured to acquire the initial updated smart contract of the original smart contract to be updated uploaded by the business object, and acquire the object attribute information of the business object;
[0141] A permission verification module 17, configured to verify the update permission of the business object for the original smart contract according to the object attribute information of the business object, and obtain a permission verification result;
[0142] A compilation module 18, configured to compile the source code file of the initial updated smart contract to obtain an executable file of the initial updated smart contract if the permission verification result indicates that the business object has the update permission for the original smart contract;
[0143] A determination module 19, configured to determine the executable file as the updated smart contract of the original smart contract.
[0144] Among them, the second acquisition module 16 includes:
[0145] A display unit 1601, configured to display a contract update interface; the contract update interface includes a contract identifier editing area, a contract details editing area, and an object information editing area;
[0146] A second acquisition unit 1602, configured to, in response to a first editing operation of the business object on the contract identifier editing area, acquire the contract identifier to be updated input by the first editing operation, and acquire the smart contract corresponding to the contract identifier to be updated from the blockchain network as the original smart contract to be updated;
[0147] A first determination unit 1603, configured to, in response to a second editing operation of the business object on the contract details editing area, determine the contract code information input by the second editing operation as the initial updated smart contract;
[0148] A second determination unit 1604, configured to, in response to a third editing operation of the business object on the object information editing area, determine the object attribute information of the business object according to the object information input by the third editing operation.
[0149] Among them, the object attribute information of the business object includes the object identifier of the business object;
[0150] The permission verification module 17 includes:
[0151] A third acquisition unit 1701, configured to acquire the identification matching degrees between the object identifier of a service object and Q permission identifiers included in a permission identifier table; the permission identifier table includes the object identifiers of permission objects having the update permission for the original smart contract; Q is a positive integer;
[0152] A third determination unit 1702, configured to determine that the service object has the update permission for the original smart contract if there is a permission identifier in the permission identifier table whose identification matching degree with the object identifier of the service object is greater than or equal to a matching degree threshold;
[0153] A first generation unit 1703, configured to generate a permission verification result for indicating that the service object has the update permission for the original smart contract.
[0154] Wherein, the first contract attribute information includes the contract data structure of the original smart contract, and the second contract attribute information includes the contract data structure of the updated smart contract;
[0155] The verification module 12 includes:
[0156] A verification unit 1201, configured to verify the compatibility between the original smart contract and the updated smart contract according to the contract data structure of the original smart contract and the contract data structure of the updated smart contract, and obtain a compatibility verification result;
[0157] A fourth determination unit 1202, configured to determine that the updated smart contract has update legality if the compatibility verification result indicates that there is compatibility between the original smart contract and the updated smart contract;
[0158] A second generation unit 1203, configured to generate a legality verification result for indicating that the updated smart contract has update legality.
[0159] Wherein, the verification unit 1201 is specifically configured to:
[0160] Acquire M original storage fields in the contract data structure of the original smart contract, and acquire S updated storage fields in the contract data structure of the updated smart contract; M and S are positive integers;
[0161] Determine M storage field pairs from the S updated storage fields and the M original storage fields; each storage field pair includes one updated storage field and one original storage field, and the position of the updated storage field in the updated smart contract in each storage field pair is the same as the position of the corresponding original storage field in the original smart contract;
[0162] When the data type of the updated storage field in each of the M pairs of storage fields is the same as the data type of the original storage field in the corresponding pair of storage fields, it is determined that there is compatibility between the original smart contract and the updated smart contract, and a compatibility verification result is generated to indicate the compatibility between the original smart contract and the updated smart contract.
[0163] Among them, the first contract attribute information includes the contract identification information of the original smart contract, and the second contract attribute information includes the contract code information of the updated smart contract;
[0164] The verification module 12 includes:
[0165] A query unit 1204, configured to query the contract log data of the original smart contract from the blockchain network according to the contract identification information of the original smart contract;
[0166] A first detection unit 1205, configured to detect the contract update characteristics of the original smart contract according to the contract log data;
[0167] A second detection unit 1206, configured to, if the contract update characteristics reflect that the original smart contract has updatability, detect the security of the updated smart contract according to the contract code information of the updated smart contract to obtain a security detection result;
[0168] A third generation unit 1207, configured to, if the security detection result indicates that the security of the updated smart contract is greater than or equal to the security threshold, determine that the updated smart contract has update contractability, and generate a legality verification result to indicate the update legality of the updated smart contract.
[0169] Among them, the first detection unit 1205 is specifically configured to:
[0170] Determine the call object of the original smart contract according to the contract log data;
[0171] If the call object is a proxy smart contract and the contract data structure of the original smart contract is stored in the proxy smart contract, it is determined that the original smart contract has updatability;
[0172] Generate contract update characteristics reflecting that the original smart contract has updatability.
[0173] Among them, the second detection unit 1206 is specifically configured to:
[0174] Perform pre-execution on the updated smart contract to obtain a pre-execution result;
[0175] If the pre-execution result reflects that the contract code of the updated smart contract is executable, call the contract security detection model to detect the security of the updated smart contract to obtain the security detection result of the updated smart contract.
[0176] Among them, the upper-chain module 14 includes:
[0177] A signature verification unit 1401, configured to receive an update confirmation signature returned by a signature object, and verify the validity of the received update confirmation signature;
[0178] A statistics unit 1402, configured to count the number of signatures of the update confirmation signatures with validity among the received update confirmation signatures;
[0179] A sending unit 1403, configured to generate a contract upper-chain transaction for updating a smart contract and send the contract upper-chain transaction to a consensus node in the blockchain network if the number of signatures is greater than or equal to a verification threshold value; the consensus node is configured to perform consensus on the contract upper-chain transaction to obtain an upper-chain consensus result;
[0180] An upper-chain unit 1404, configured to receive the upper-chain consensus result returned by the consensus node, and if the upper-chain consensus result indicates that the consensus node has successfully consensus on the contract upper-chain transaction, then upload the updated smart contract to the blockchain of the blockchain network.
[0181] In the embodiments of the present application, the term "module" or "unit" refers to a computer program with a predetermined function or a part of a computer program, which works together with other related parts to achieve a predetermined goal, and can be fully or partially implemented by using software, hardware (such as a processing circuit or a memory), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of an overall module or unit including the function of the module or unit. According to an embodiment of the present application, Figure 9 Each module in the blockchain-based data processing device shown can be separately or all combined into one or several units to form, or a certain one (or some) of the units can be further split into at least two sub-units with smaller functions, and the same operations can be achieved without affecting the realization of the technical effects of the embodiments of the present application. The above modules are divided based on logical functions. In practical applications, the function of a module can also be implemented by at least two units, or the functions of at least two modules can be implemented by one unit. In other embodiments of the present application, the blockchain-based data processing device can also include other units. In practical applications, these functions can also be assisted by other units and can be implemented by the cooperation of at least two units.
[0182] According to an embodiment of the present application, it can be achieved by running on a general computer device such as a computer including processing elements and storage elements such as a central processing unit (CPU), a random access storage medium (RAM), and a read-only storage medium (ROM) that can execute as Figure 7Or Figure 8 a computer program (including program code) for each step involved in the corresponding method shown in Figure 9 to construct a blockchain-based data processing device as shown in
[0183] An embodiment of the present application provides a pipeline service for automatic update of smart contracts, which can ensure the security of the update of the original smart contract while realizing the automatic update of the original smart contract. Specifically, by using the first contract attribute information of the original smart contract and the second contract attribute information of the updated smart contract, the update legality of the updated smart contract is verified, which can avoid the situation that the updated smart contract contains malicious attack code, or the updated smart contract is incompatible with the original smart contract, resulting in update failure, and can ensure the stability and reliability of the update of the original smart contract. When the updated smart contract has update legality, a contract update request for instructing to update the original smart contract with the updated smart contract is sent to a signature object associated with the original smart contract, and an update confirmation signature returned by the signature object is received. When the number of valid update confirmation signatures in the received update confirmation signatures is greater than or equal to the verification threshold value, the updated smart contract is uploaded to the blockchain of the blockchain network, which can ensure the security of the update of the original smart contract. It can be seen that the approval of the contract update request by the signature object can further improve the security and reliability of the update of the original smart contract and avoid the update of the original smart contract by illegal objects. The proxy smart contract corresponding to the original smart contract is called to update the original smart contract according to the updated smart contract. It can be seen that the pipeline service for automatic update of smart contracts provided by the embodiment of the present application can realize the automatic update of smart contracts. Business objects do not need to write underlying code for each smart contract to implement the contract update of the smart contract, saving time and effort, improving the efficiency of smart contract update, and at the same time can improve the stability and reliability of the updated smart contract, thereby improving the security of the update of the original smart contract.
[0184] Further, please refer to Figure 10 , Figure 10 which is a schematic diagram of a computer device provided by an embodiment of the present application. As Figure 10 shown, the computer device 3000 may be the above-mentioned Figure 2For the terminal device or blockchain node in the corresponding embodiment, the computer device 3000 may include: at least one processor 3001, such as a CPU, at least one network interface 3004, a user interface 3003, a memory 3005, and at least one communication bus 3002. Among them, the communication bus 3002 is used to implement connection communication between these components. Among them, the user interface 3003 may include a display screen (Display) and a keyboard (Keyboard). Optionally, the network interface 3004 may include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 3005 may be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory. Optionally, the storage 3005 may also be at least one storage device located far from the aforementioned processor 3001. As Figure 10 shown, the memory 3005, as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a device control application program.
[0185] In Figure 10 the computer device 3000 shown, the network interface 3004 is mainly used for the second node device to communicate with the target relay server and the target oracle server; while the user interface 3003 is mainly used to provide an input interface for users; and the processor 3001 can be used to call the device control application program stored in the memory 3005 to implement:
[0186] Obtain the first contract attribute information of the original smart contract to be updated in the blockchain network, and the second contract attribute information of the updated smart contract of the original smart contract;
[0187] According to the first contract attribute information and the second contract attribute information, verify the update legality of the updated smart contract to obtain a legality verification result;
[0188] If the legality verification result indicates that the updated smart contract has update legality, generate a contract update request for instructing to update the original smart contract with the updated smart contract, and send the contract update request to the signature object associated with the original smart contract; the signature object is used to generate an update confirmation signature according to the contract update request;
[0189] Receive the update confirmation signature returned by the signature object, and according to the received update confirmation signature, upload the updated smart contract to the blockchain of the blockchain network;
[0190] Call the proxy smart contract corresponding to the original smart contract, and update the original smart contract according to the updated smart contract.
[0191] It should be understood that the computer device 3000 described in the embodiments of the present application can also execute the description of the blockchain-based data processing method in the corresponding embodiments described above. The computer device 3000 described in the embodiments of the present application can also execute the description of the blockchain-based data processing device in the corresponding embodiments described above, which will not be elaborated here. In addition, the description of the beneficial effects of using the same method will not be elaborated either. Figure 8 It should be understood that the computer device 3000 described in the embodiments of the present application can also execute the description of the blockchain-based data processing method in the corresponding embodiments described above. The computer device 3000 described in the embodiments of the present application can also execute the description of the blockchain-based data processing device in the corresponding embodiments described above, which will not be elaborated here. In addition, the description of the beneficial effects of using the same method will not be elaborated either. Figure 9 It will not be elaborated here. In addition, the description of the beneficial effects of using the same method will not be elaborated either.
[0192] In addition, it should be noted here that: The embodiments of the present application also provide a computer-readable storage medium, and the computer-readable storage medium stores the computer program executed by the blockchain-based data processing device mentioned above. The computer program includes program instructions. When the processor executes the program instructions, it can execute the description of the blockchain-based data processing method in the corresponding embodiments described above, so it will not be elaborated here. In addition, the description of the beneficial effects of using the same method will not be elaborated either. For the technical details not disclosed in the embodiments of the computer-readable storage medium involved in the present application, please refer to the description of the method embodiments of the present application. As an example, the program instructions can be deployed to be executed on one computing device, or on multiple computing devices located at one location, or on multiple computing devices distributed at multiple locations and interconnected through a communication network. The multiple computing devices distributed at multiple locations and interconnected through a communication network can form a blockchain system. Figure 7 or Figure 8 It will not be elaborated here. In addition, the description of the beneficial effects of using the same method will not be elaborated either. For the technical details not disclosed in the embodiments of the computer-readable storage medium involved in the present application, please refer to the description of the method embodiments of the present application. As an example, the program instructions can be deployed to be executed on one computing device, or on multiple computing devices located at one location, or on multiple computing devices distributed at multiple locations and interconnected through a communication network. The multiple computing devices distributed at multiple locations and interconnected through a communication network can form a blockchain system.
[0193] On the one hand, the present application provides a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device can execute the description of the blockchain-based data processing method in the corresponding embodiments described above, which will not be elaborated here. In addition, the description of the beneficial effects of using the same method will not be elaborated either. Figure 7 or Figure 8 It will not be elaborated here. In addition, the description of the beneficial effects of using the same method will not be elaborated either.
[0194] It should be noted that in the practical application of the relevant data collection and processing in the present application, it should strictly comply with the requirements of relevant national laws and regulations, obtain the informed consent or separate consent (or have a legal basis) of the personal information subject, and carry out subsequent data use and processing behaviors within the scope authorized by laws and regulations and the personal information subject. For example, when the present application obtains the object attribute information (such as object identification information, object name information, and object contact information) of the business object, it is necessary to obtain the informed consent or separate consent of the business object.
[0195] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The above program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. Among them, the above storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.
[0196] The above-disclosed are only the preferred embodiments of the present application. Of course, the scope of rights of the present application cannot be limited thereby. Therefore, equivalent changes made according to the claims of the present application still fall within the scope covered by the present application.
Claims
1. A data processing method based on blockchain, characterized in that: include: Obtaining first contract attribute information of an original smart contract to be updated in the blockchain network, and second contract attribute information of an updated smart contract of the original smart contract; Verify the legality of the update of the updated smart contract according to the first contract attribute information and the second contract attribute information to obtain a legality verification result; If the legitimacy check result indicates that the updated smart contract has update legitimacy, a contract update request is generated for indicating that the updated smart contract is used to update the original smart contract, and the contract update request is sent to the signature object associated with the original smart contract; the signature object is used to generate an update confirmation signature according to the contract update request; Receive the update confirmation signature returned by the signature object, and upload the update smart contract to the blockchain of the blockchain network according to the received update confirmation signature; The proxy smart contract corresponding to the original smart contract is called, and the original smart contract is updated according to the updated smart contract.
2. The method according to claim 1, characterized in that The calling of the proxy smart contract corresponding to the original smart contract, and updating the original smart contract according to the updated smart contract, includes: Calling the proxy smart contract corresponding to the original smart contract to obtain the updated contract address of the updated smart contract on the blockchain; According to the updated contract address, the original contract address in the proxy smart contract is updated; the original contract address is the address of the original smart contract on the blockchain; According to the updated storage field in the contract data structure of the updated smart contract, the original storage field in the proxy smart contract is updated; the original storage field belongs to the data in the contract data structure of the original smart contract.
3. The method according to claim 2, characterized in that The updating of the original contract address in the proxy smart contract according to the updated contract address includes: Generate an address change transaction for indicating that the original contract address in the proxy smart contract is changed to the updated contract address; Sending the address change transaction to a consensus node in the blockchain network; the consensus node is used to reach a consensus on the address change transaction and obtain a change consensus result; The consensus change result returned by the consensus node is received, and if the consensus change result indicates that the consensus node has successfully reached consensus on the address change transaction, the original contract address in the proxy smart contract is changed to the updated contract address.
4. The method according to claim 1, characterized in that: The method comprises: Obtaining an initial update smart contract of the original smart contract to be updated uploaded by the business object, and obtaining object attribute information of the business object; Verify the update authority of the business object for the original smart contract according to the object attribute information of the business object, and obtain an authority verification result; If the permission verification result indicates that the business object has the update permission for the original smart contract, compile the source code file of the initial update smart contract to obtain an executable file of the initial update smart contract; The executable file is determined as an updated smart contract of the original smart contract.
5. The method according to claim 4, characterized in that The obtaining of the initial update smart contract of the original smart contract to be updated uploaded by the business object, and obtaining the object attribute information of the business object, includes: Display the contract update interface; the contract update interface includes a contract identification editing area, a contract details editing area, and an object information editing area; In response to a first editing operation of the business object on the contract identifier editing area, obtaining the contract identifier to be updated input by the first editing operation, and obtaining a smart contract corresponding to the contract identifier to be updated from the blockchain network as the original smart contract to be updated; In response to a second editing operation of the business object on the contract details editing area, determining the contract code information input by the second editing operation as an initial update smart contract; In response to a third editing operation of the business object on the object information editing area, object attribute information of the business object is determined according to the object information input by the third editing operation.
6. The method according to claim 4, characterized in that The object attribute information of the business object includes the object identifier of the business object; The step of verifying the update authority of the business object for the original smart contract according to the object attribute information of the business object to obtain the authority verification result includes: Obtaining the object identifier of the business object and the identifier matching degree between each of the Q authority identifiers included in the authority identifier table; the authority identifier table includes the object identifier of the authority object having the update authority for the original smart contract; Q is a positive integer; If there is a permission identifier in the permission identifier table whose identifier matching degree with the object identifier of the business object is greater than or equal to the matching degree threshold, it is determined that the business object has the update permission for the original smart contract; Generate a permission verification result indicating that the business object has update permission for the original smart contract.
7. The method according to claim 1, characterized in that The first contract attribute information includes the contract data structure of the original smart contract, and the second contract attribute information includes the contract data structure of the updated smart contract; The verifying the update legality of the updated smart contract according to the first contract attribute information and the second contract attribute information to obtain a legality verification result includes: Verify the compatibility between the original smart contract and the updated smart contract according to the contract data structure of the original smart contract and the contract data structure of the updated smart contract to obtain a compatibility verification result; If the compatibility check result indicates that the original smart contract and the updated smart contract are compatible, then determining that the updated smart contract has update legitimacy; Generate a legitimacy verification result indicating that the updated smart contract has the legitimacy of the update.
8. The method according to claim 7, characterized in that The compatibility check between the original smart contract and the updated smart contract is performed according to the contract data structure of the original smart contract and the contract data structure of the updated smart contract to obtain a compatibility check result, including: Obtain M original storage fields in the contract data structure of the original smart contract, and obtain S updated storage fields in the contract data structure of the updated smart contract; M and S are positive integers; Determine M storage field pairs from the S updated storage fields and the M original storage fields; each of the storage field pairs includes an updated storage field and an original storage field, and the position of the updated storage field in each storage field pair in the updated smart contract is the same as the position of the original storage field in the corresponding storage field pair in the original smart contract; When the data type of the updated storage field of each of the M storage field pairs is the same as the data type of the original storage field of the corresponding storage field pair, it is determined that the original smart contract is compatible with the updated smart contract, and a compatibility verification result is generated to indicate that the original smart contract is compatible with the updated smart contract.
9. The method according to claim 1, characterized in that: The first contract attribute information includes the contract identification information of the original smart contract, and the second contract attribute information includes the contract code information of the updated smart contract; The verifying the update legality of the updated smart contract according to the first contract attribute information and the second contract attribute information to obtain a legality verification result includes: According to the contract identification information of the original smart contract, query the contract log data of the original smart contract from the blockchain network; Detecting a contract update feature of the original smart contract based on the contract log data; If the contract update characteristic reflects that the original smart contract is renewable, the security of the updated smart contract is tested according to the contract code information of the updated smart contract to obtain a security test result; If the security detection result indicates that the security of the updated smart contract is greater than or equal to the security threshold, it is determined that the updated smart contract has updated contractuality, and a legitimacy verification result is generated to indicate that the updated smart contract has updated legitimacy.
10. The method according to claim 9, characterized in that The detecting the contract update characteristic of the original smart contract according to the contract log data includes: Determine the calling object of the original smart contract according to the contract log data; If the calling object is a proxy smart contract, and the proxy smart contract stores the contract data structure of the original smart contract, then determining that the original smart contract has an updateable feature; A contract update property is generated to reflect that the original smart contract is renewable.
11. The method according to claim 9, characterized in that The step of testing the security of the updated smart contract according to the contract code information of the updated smart contract to obtain a security testing result includes: Pre-execute the contract code information of the updated smart contract to obtain a pre-execution result; If the pre-execution result reflects that the contract code of the updated smart contract is executable, the contract security detection model is called to detect the security of the updated smart contract to obtain the security detection result of the updated smart contract.
12. The method according to claim 1, characterized in that The receiving the update confirmation signature returned by the signature object, and uploading the update smart contract to the blockchain of the blockchain network according to the received update confirmation signature, includes: Receive the update confirmation signature returned by the signature object, and verify the validity of the received update confirmation signature; Count the number of valid update confirmation signatures among the received update confirmation signatures; If the number of signatures is greater than or equal to the verification threshold, a contract on-chain transaction for updating the smart contract is generated, and the contract on-chain transaction is sent to a consensus node in the blockchain network; the consensus node is used to reach a consensus on the contract on-chain transaction and obtain a consensus result on the chain; Receive the on-chain consensus result returned by the consensus node. If the on-chain consensus result indicates that the consensus node has successfully reached consensus on the on-chain transaction of the contract, then the updated smart contract is uploaded to the blockchain of the blockchain network.
13. A data processing device based on blockchain, characterized in that: include: A first acquisition module, used to acquire first contract attribute information of an original smart contract to be updated in the blockchain network, and second contract attribute information of an updated smart contract of the original smart contract; A verification module, used to verify the legality of the update of the updated smart contract according to the first contract attribute information and the second contract attribute information, and obtain a legality verification result; A sending module, configured to generate a contract update request for instructing to update the original smart contract using the updated smart contract if the legitimacy check result indicates that the updated smart contract has update legitimacy, and send the contract update request to a signature object associated with the original smart contract; the signature object is configured to generate an update confirmation signature according to the contract update request; An on-chain module, used to receive the update confirmation signature returned by the signature object, and on-chain the update smart contract to the blockchain of the blockchain network according to the received update confirmation signature; The update module is used to call the proxy smart contract corresponding to the original smart contract and update the original smart contract according to the update smart contract.
14. A computer device, characterized in that: include: Processor and memory; The processor is connected to a memory, wherein 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 according to any one of claims 1 to 12.
15. 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 12.
16. A computer program product or a computer program, characterized in that The computer program product or computer program comprises computer instructions, which are stored in a computer-readable storage medium and are 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 12.