WO2022252995A1 - Smart contract deployment method and apparatus - Google Patents

Smart contract deployment method and apparatus Download PDF

Info

Publication number
WO2022252995A1
WO2022252995A1 PCT/CN2022/093802 CN2022093802W WO2022252995A1 WO 2022252995 A1 WO2022252995 A1 WO 2022252995A1 CN 2022093802 W CN2022093802 W CN 2022093802W WO 2022252995 A1 WO2022252995 A1 WO 2022252995A1
Authority
WO
WIPO (PCT)
Prior art keywords
task
blockchain
node
code
contract
Prior art date
Application number
PCT/CN2022/093802
Other languages
French (fr)
Chinese (zh)
Inventor
郭学鹏
Original Assignee
支付宝(杭州)信息技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 支付宝(杭州)信息技术有限公司 filed Critical 支付宝(杭州)信息技术有限公司
Publication of WO2022252995A1 publication Critical patent/WO2022252995A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/34Network arrangements or protocols for supporting network services or applications involving the movement of software or configuration parameters 
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/2866Architectures; Arrangements
    • H04L67/30Profiles
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Abstract

Provided in one or more embodiments of the present description are a smart contract deployment method and apparatus. The method comprises: acquiring a task code generated by means of describing a workflow by using a workflow description language; compiling the task code by means of a compiler, so as to generate a contract code for representing the workflow; and sending, to a blockchain network, a blockchain transaction for deploying the contract code, so as to deploy a corresponding smart contract in the blockchain network, wherein the smart contract is used for allocating, when being called and according to service logic defined by each task node in the workflow, a task to be executed to a node member which participates in the blockchain network.

Description

智能合约部署的方法及装置Method and device for smart contract deployment 技术领域technical field
本说明书实施例涉及区块链技术领域,尤其涉及一种智能合约部署的方法及装置。The embodiment of this specification relates to the field of blockchain technology, and in particular to a method and device for smart contract deployment.
背景技术Background technique
区块链技术构建在传输网络(例如点对点网络)之上。区块链网络中的节点利用链式数据结构来验证与存储数据,并采用分布式节点共识算法来生成和更新数据。在一些区块链网络中,部分节点有时存在实现小范围交易的需求,以避免其他节点获得这些交易及其相关数据,因此可以在区块链主网的基础上进一步建立区块链子网。Blockchain technology is built on top of transmission networks such as peer-to-peer networks. Nodes in the blockchain network use chained data structures to verify and store data, and use distributed node consensus algorithms to generate and update data. In some blockchain networks, some nodes sometimes need to implement small-scale transactions to prevent other nodes from obtaining these transactions and their related data. Therefore, a blockchain subnet can be further established on the basis of the blockchain main network.
区块链主网或区块链子网中可以部署对应于具体业务的智能合约。在相关技术中,通常由用户或技术人员通过手动编程的方式编写智能合约的合约代码,因此智能合代码标准化程度较低,不利于智能合约的生成以及执行,限制了智能合约的部署及执行效率。Smart contracts corresponding to specific businesses can be deployed in the blockchain main network or blockchain subnet. In related technologies, the contract code of smart contracts is usually written by users or technicians through manual programming. Therefore, the standardization of smart contract codes is low, which is not conducive to the generation and execution of smart contracts, and limits the deployment and execution efficiency of smart contracts. .
发明内容Contents of the invention
有鉴于此,本说明书一个或多个实施例提供一种智能合约部署方法及装置。In view of this, one or more embodiments of this specification provide a smart contract deployment method and device.
为实现上述目的,根据本说明书一个或多个实施例的第一方面,提出了一种智能合约部署方法,包括:获取使用工作流描述语言对工作流进行描述而生成的任务代码;通过编译器对所述任务代码进行编译,生成用于表征所述工作流的合约代码;向区块链网络发送用于部署所述合约代码的区块链交易,以在所述区块链网络中部署相应的智能合约,所述智能合约用于在被调用时根据所述工作流中各任务结点所定义的业务逻辑向参与所述区块链网络的节点成员分配待执行任务。In order to achieve the above purpose, according to the first aspect of one or more embodiments of this specification, a smart contract deployment method is proposed, including: obtaining the task code generated by using the workflow description language to describe the workflow; Compile the task code to generate a contract code representing the workflow; send a blockchain transaction for deploying the contract code to the blockchain network to deploy the corresponding task code in the blockchain network The smart contract is used to assign tasks to be executed to the node members participating in the blockchain network according to the business logic defined by each task node in the workflow when called.
根据本说明书一个或多个实施例的第二方面,提出了一种智能合约部署方法,应用于区块链网络中的区块链节点,包括:响应于接收到的部署合约代码的区块链交易,在所述区块链网络中部署相应的智能合约;所述合约代码由编译器对任务代码进行编译而生成,所述任务代码由工作流描述语言对工作流进行描述而生成;响应于接收到的调用所述智能合约的区块链交易,根据所述工作流中各任务结点所定义的业务逻辑向参与所述区块链网络的节点成员分配待执行任务。According to the second aspect of one or more embodiments of this specification, a smart contract deployment method is proposed, which is applied to the blockchain nodes in the blockchain network, including: responding to the received blockchain deployment contract code transaction, deploying the corresponding smart contract in the blockchain network; the contract code is generated by compiling the task code by the compiler, and the task code is generated by describing the workflow in the workflow description language; in response to The received block chain transaction calling the smart contract assigns tasks to be executed to the node members participating in the block chain network according to the business logic defined by each task node in the workflow.
根据本说明书一个或多个实施例的第三方面,提出了一种智能合约部署装置,包括:代码获取单元,使获取使用工作流描述语言对工作流进行描述而生成的任务代码;代码编译单元,使通过编译器对所述任务代码进行编译,生成用于表征所述工作流的合约代码;交易部署单元,使向区块链网络发送用于部署所述合约代码的区块链交易,以在所述区块链网络中部署相应的智能合约,所述智能合约用于在被调用时根据所述工作流中各任务结点所定义的业务逻辑向参与所述区块链网络的节点成员分配待执行任务。According to a third aspect of one or more embodiments of the present specification, a smart contract deployment device is proposed, including: a code acquisition unit that acquires the task code generated by describing the workflow using a workflow description language; a code compilation unit , so that the task code is compiled by the compiler to generate the contract code used to represent the workflow; the transaction deployment unit is used to send the blockchain transaction used to deploy the contract code to the blockchain network to Deploy the corresponding smart contract in the blockchain network, and the smart contract is used to report to the node members participating in the blockchain network according to the business logic defined by each task node in the workflow when called Assign pending tasks.
根据本说明书一个或多个实施例的第四方面,提出了一种智能合约部署装置,应用于区块链网络中的区块链节点,包括:合约部署单元,使响应于接收到的部署合约代码的区块链交易,在所述区块链网络中部署相应的智能合约;所述合约代码由编译器对任务代码进行编译而生成,所述任务代码由工作流描述语言对工作流进行描述而生成;合约调用单元,使响应于接收到的调用所述智能合约的区块链交易,根据所述工作流中各任务结点所定义的业务逻辑向参与所述区块链网络的节点成员分配待执行任务。According to a fourth aspect of one or more embodiments of this specification, a smart contract deployment device is proposed, which is applied to a blockchain node in a blockchain network, including: a contract deployment unit that responds to the received deployment contract The blockchain transaction of the code, deploy the corresponding smart contract in the blockchain network; the contract code is generated by compiling the task code by the compiler, and the task code describes the workflow by the workflow description language and generate; the contract invoking unit responds to the block chain transaction of calling the smart contract received, according to the business logic defined by each task node in the workflow, to the node members participating in the block chain network Assign pending tasks.
根据本说明书一个或多个实施例的第五方面,提出了一种电子设备,包括:处理器;用于存储处理器可执行指令的存储器;其中,所述处理器通过运行所述可执行指令以实现如第一方面或第二方面所述的方法。According to a fifth aspect of one or more embodiments of the present specification, an electronic device is provided, including: a processor; a memory for storing processor-executable instructions; wherein, the processor executes the executable instructions To realize the method described in the first aspect or the second aspect.
根据本说明书一个或多个实施例的第六方面,提出了一种计算机可读存储介质,其上存储有计算机指令,该指令被处理器执行时实现如第一方面或第二方面所述方法的步骤。According to a sixth aspect of one or more embodiments of the present specification, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, the method described in the first aspect or the second aspect is implemented. A step of.
附图说明Description of drawings
图1是一示例性实施例提供的一种创建智能合约的示意图。Fig. 1 is a schematic diagram of creating a smart contract provided by an exemplary embodiment.
图2是一示例性实施例提供的一种调用智能合约的示意图。Fig. 2 is a schematic diagram of invoking a smart contract provided by an exemplary embodiment.
图3是一示例性实施例提供的一种创建和调用智能合约的示意图。Fig. 3 is a schematic diagram of creating and invoking a smart contract provided by an exemplary embodiment.
图4是一示例性实施例提供的一种基于区块链主网组建区块链子网的示意图。Fig. 4 is a schematic diagram of building a blockchain subnet based on the blockchain main network provided by an exemplary embodiment.
图5是一示例性实施例提供的一种智能合约部署方法的流程图。Fig. 5 is a flowchart of a smart contract deployment method provided by an exemplary embodiment.
图6是一示例性实施例提供的另一种智能合约部署方法的流程图。Fig. 6 is a flowchart of another smart contract deployment method provided by an exemplary embodiment.
图7是一示例性实施例提供的又一种智能合约部署方法的流程图。Fig. 7 is a flowchart of another smart contract deployment method provided by an exemplary embodiment.
图8是一示例性实施例提供的一种设备的结构示意图。Fig. 8 is a schematic structural diagram of a device provided by an exemplary embodiment.
图9是一示例性实施例提供的一种智能合约部署装置的框图。Fig. 9 is a block diagram of a smart contract deployment device provided by an exemplary embodiment.
图10是一示例性实施例提供的另一种智能合约部署装置的框图。Fig. 10 is a block diagram of another smart contract deployment device provided by an exemplary embodiment.
具体实施方式Detailed ways
这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本说明书一个或多个实施例相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本说明书一个或多个实施例的一些方面相一致的装置和方法的例子。Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numerals in different drawings refer to the same or similar elements unless otherwise indicated. Implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Rather, they are merely examples of apparatuses and methods consistent with aspects of one or more embodiments of the present specification as recited in the appended claims.
需要说明的是:在其他实施例中并不一定按照本说明书示出和描述的顺序来执行相应方法的步骤。在一些其他实施例中,其方法所包括的步骤可以比本说明书所描述的更多或更少。此外,本说明书中所描述的单个步骤,在其他实施例中可能被分解为多个步骤进行描述;而本说明书中所描述的多个步骤,在其他实施例中也可能被合并为单个步骤进行描述。It should be noted that in other embodiments, the steps of the corresponding methods are not necessarily performed in the order shown and described in this specification. In some other embodiments, the method may include more or less steps than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; multiple steps described in this specification may also be combined into a single step in other embodiments describe.
区块链一般被划分为三种类型:公有链(Public Blockchain),私有链(Private Blockchain)和联盟链(Consortium Blockchain)。此外,还有多种类型的结合,比如私有链+联盟链、联盟链+公有链等不同组合形式。其中去中心化程度最高的是公有链。公有链以比特币、以太坊为代表,加入公有链的参与者可以读取链上的数据记录、参与交易以及竞争新区块的记账权等。而且,各参与者(即节点)可自由加入以及退出网络,并进行相关操作。私有链则相反,该网络的写入权限由某个组织或者机构控制,数据读取权限受组织规定。简单来说,私有链可以为一个弱中心化系统,参与节点具有严格限制且少。这种类型的区块链更适合于特定机构内部使用。联盟链则是介于公有链以及私有链之间的区块链,可实现“部分去中心化”。联盟链中各个节点通常有与之相对应的实体机构或者组织;参与者通过授权加入网络并组成利益相关联盟,共同维护区块链运行。Blockchains are generally divided into three types: Public Blockchain, Private Blockchain and Consortium Blockchain. In addition, there are many types of combinations, such as private chain + alliance chain, alliance chain + public chain and other combinations. Among them, the public chain has the highest degree of decentralization. The public chain is represented by Bitcoin and Ethereum. Participants who join the public chain can read the data records on the chain, participate in transactions, and compete for the bookkeeping rights of new blocks. Moreover, each participant (ie node) can freely join and exit the network and perform related operations. On the contrary, the private chain, the write permission of the network is controlled by an organization or institution, and the data read permission is regulated by the organization. In simple terms, the private chain can be a weakly centralized system with strict restrictions and few participating nodes. This type of blockchain is more suitable for internal use by specific institutions. The alliance chain is a blockchain between the public chain and the private chain, which can realize "partial decentralization". Each node in the consortium chain usually has a corresponding entity or organization; participants join the network through authorization and form an alliance of stakeholders to jointly maintain the operation of the blockchain.
不论是公有链、私有链还是联盟链,都可能提供智能合约的功能。区块链上的智能合约是在区块链系统上可以被交易触发执行的合约。智能合约可以通过代码的形式定义。Whether it is a public chain, a private chain or an alliance chain, it is possible to provide the function of smart contracts. Smart contracts on the blockchain are contracts that can be triggered by transactions on the blockchain system. Smart contracts can be defined in the form of code.
以以太坊为例,支持用户在以太坊网络中创建并调用一些复杂的逻辑,这是以太坊区别于比特币区块链技术的最大挑战。以太坊作为一个可编程区块链的核心是以太坊虚拟机(EVM),每个以太坊节点都可以运行EVM。EVM是一个图灵完备的虚拟机,这意味着可以通过它实现各种复杂的逻辑。用户在以太坊中发布和调用智能合约就是在EVM上运行的。实际上,虚拟机直接运行的是虚拟机代码(虚拟机字节码,下简称“字节码”)。部署在区块链上的智能合约可以是字节码的形式。Taking Ethereum as an example, it supports users to create and invoke some complex logic in the Ethereum network, which is the biggest challenge that distinguishes Ethereum from Bitcoin blockchain technology. The core of Ethereum as a programmable blockchain is the Ethereum Virtual Machine (EVM), and each Ethereum node can run the EVM. EVM is a Turing-complete virtual machine, which means that various complex logic can be implemented through it. Users publish and call smart contracts in Ethereum that run on the EVM. In fact, the virtual machine directly runs virtual machine code (virtual machine bytecode, hereinafter referred to as “bytecode”). Smart contracts deployed on the blockchain can be in the form of bytecode.
例如图1所示,Bob将一个包含创建智能合约信息的交易发送到以太坊网络后,节点1的EVM可以执行这个交易并生成对应的合约实例。图1中的“0x6f8ae93…”代表了这个合约的地址,交易的data字段保存的可以是字节码,交易的to字段为空。节点间通过共识机制达成一致后,这个合约成功创建,并且可以在后续过程中被调用。合约创建后,区块链上出现一个与该智能合约对应的合约账户,并拥有一个特定的地址,合约代码将保存在该合约账户中。智能合约的行为由合约代码控制。换句话说,智能合约使得区块链上产生包含合约代码和账户存储(Storage)的虚拟账户。For example, as shown in Figure 1, after Bob sends a transaction containing information about creating a smart contract to the Ethereum network, the EVM of node 1 can execute the transaction and generate a corresponding contract instance. "0x6f8ae93..." in Figure 1 represents the address of this contract, the data field of the transaction can store bytecode, and the to field of the transaction is empty. After the nodes reach a consensus through the consensus mechanism, the contract is successfully created and can be called in the subsequent process. After the contract is created, a contract account corresponding to the smart contract appears on the blockchain and has a specific address, and the contract code will be saved in the contract account. The behavior of smart contracts is controlled by the contract code. In other words, the smart contract makes a virtual account containing contract code and account storage (Storage) generated on the blockchain.
如图2所示,仍以以太坊为例,Bob将一个用于调用智能合约的交易发送到以太坊网络后,某一节点的EVM可以执行这个交易并生成对应的合约实例。图2中交易的from 字段是交易发起方(即Bob)的账户的地址,to字段中的“0x6f8ae93…”代表了被调用的智能合约的地址,value字段在以太坊中是以太币的值,交易的data字段保存的调用智能合约的方法和参数。调用智能合约后,balance的值可能改变。后续,某个客户端可以通过某一区块链节点(例如图2中的节点6)查看balance的当前值。智能合约以规定的方式在区块链网络中每个节点独立的执行,所有执行记录和数据都保存在区块链上,所以当交易完成后,区块链上就保存了无法篡改、不会丢失的交易凭证。As shown in Figure 2, still taking Ethereum as an example, after Bob sends a transaction for calling a smart contract to the Ethereum network, the EVM of a certain node can execute this transaction and generate a corresponding contract instance. The from field of the transaction in Figure 2 is the address of the account of the transaction initiator (ie Bob), the "0x6f8ae93..." in the to field represents the address of the called smart contract, and the value field is the value of Ethereum in Ethereum. The method and parameters of calling the smart contract are saved in the data field of the transaction. After calling the smart contract, the value of balance may change. Subsequently, a client can view the current value of balance through a certain blockchain node (such as node 6 in Figure 2). Smart contracts are independently executed by each node in the blockchain network in a prescribed manner, and all execution records and data are stored on the blockchain, so when the transaction is completed, the blockchain will store data that cannot be tampered with and will not be tampered with. Lost transaction credentials.
创建智能合约和调用智能合约的示意图如图3所示。以太坊中要创建一个智能合约,需要经过编写智能合约、编译成字节码、部署到区块链等过程。以太坊中调用智能合约,是发起一笔指向智能合约地址的交易,智能合约代码分布式的运行在以太坊网络中每个节点的虚拟机中。The schematic diagram of creating a smart contract and calling a smart contract is shown in Figure 3. To create a smart contract in Ethereum, you need to go through the process of writing a smart contract, compiling it into bytecode, and deploying it to the blockchain. Calling a smart contract in Ethereum is to initiate a transaction pointing to the address of the smart contract, and the code of the smart contract is distributed and runs in the virtual machine of each node in the Ethereum network.
需要说明的是,除了可以由用户创建智能合约,也可以在创世块中由系统设置智能合约。这类合约一般称为创世合约。一般的,创世合约中可以设置一些区块链网络的数据结构、参数、属性和方法。此外,具有系统管理员权限的账户可以创建系统级的合约,或者修改系统级的合约(简称为系统合约)。另外除了以太坊中的EVM外,不同的区块链网络还可能采用各种的虚拟机,这里并不限定。It should be noted that in addition to creating smart contracts by users, smart contracts can also be set by the system in the genesis block. This type of contract is generally called a genesis contract. Generally, some blockchain network data structures, parameters, properties and methods can be set in the genesis contract. In addition, accounts with system administrator privileges can create system-level contracts or modify system-level contracts (referred to as system contracts). In addition to the EVM in Ethereum, different blockchain networks may also use various virtual machines, which are not limited here.
区块链网络中的节点在执行调用智能合约的交易后,会生成相应的收据(receipt),以用于记录与执行该智能合约相关的信息。这样,可以通过查询交易的收据来获得合约执行结果的相关信息。合约执行结果可以表现为收据中的事件(event)。消息机制可以通过收据中的事件实现消息传递,以触发区块链节点执行相应的处理。事件的结构譬如可以为:After the nodes in the blockchain network execute the transaction that invokes the smart contract, they will generate a corresponding receipt (receipt), which is used to record information related to the execution of the smart contract. In this way, information about the contract execution result can be obtained by querying the receipt of the transaction. Contract execution results can be expressed as events in receipts. The message mechanism can implement message delivery through events in the receipt to trigger blockchain nodes to perform corresponding processing. The structure of an event can be, for example:
Event:Event:
[topic][data][topic][data]
[topic][data][topic][data]
...... …
在上述示例中,事件的数量可以为一个或多个;其中,每个事件分别包括主题(topic)和数据(data)等字段。区块链节点可以通过监听事件的topic,从而在监听到预定义的topic的情况下,执行预设处理,或者从相应事件的data字段读取相关内容,以及可以基于读取的内容执行预设处理。In the above example, there may be one or more events; each event includes fields such as topic and data. Blockchain nodes can listen to the topic of the event to perform preset processing when listening to a predefined topic, or read relevant content from the data field of the corresponding event, and can execute preset based on the read content deal with.
上述的事件机制中,相当于在监听方(比如存在监听需求的用户)处存在具有监听功能的客户端,譬如该客户端上运行了用于实现监听功能的SDK等,由该客户端对区块链节点产生的事件进行监听,而区块链节点只需要正常生成收据即可。除了上述的事件机制之外,还可以通过其他方式实现交易信息的透出。例如,可以通过在区块链节点运行的区块链平台代码中嵌入监听代码,使得该监听代码可以监听区块链交易的交易内容、智能合约的合约状态、合约产生的收据等其中的一种或多种数据,并将监听到的数据发送至预定义的监听方。由于监听代码部署于区块链平台代码中,而非监听方的客户端处,因而相比于事件机制而言,这种基于监听代码的实现方式相对更加的主动。其中,上述的监听代码可以由区块链平台的开发人员在开发过程中加入区块链平台代码,也可以由监听方基于自身的需求而嵌入,本说明书并不对此进行限制。In the above event mechanism, it is equivalent to the presence of a client with monitoring function at the listening party (such as a user with a monitoring requirement). The events generated by the block chain nodes are monitored, and the block chain nodes only need to generate receipts normally. In addition to the above-mentioned event mechanism, transaction information disclosure can also be realized in other ways. For example, the monitoring code can be embedded in the blockchain platform code running on the blockchain node, so that the monitoring code can monitor the transaction content of the blockchain transaction, the contract status of the smart contract, the receipt generated by the contract, etc. or multiple types of data, and send the monitored data to a predefined listener. Since the monitoring code is deployed in the blockchain platform code instead of the listener's client, this implementation based on the monitoring code is relatively more active than the event mechanism. Among them, the above monitoring code can be added to the blockchain platform code by the developers of the blockchain platform during the development process, or can be embedded by the monitoring party based on its own needs, which is not limited in this manual.
区块链技术区别于传统技术的去中心化特点之一,就是在各个节点上进行记账,或者称为分布式记账,而不是传统的集中式记账。区块链系统要成为一个难以攻破的、公开的、不可篡改数据记录的去中心化诚实可信系统,需要在尽可能短的时间内做到分布式数据记录的安全、明确及不可逆。不同类型的区块链网络中,为了在各个记录账本的节点中保持账本的一致,通常采用共识算法来保证,即前述提到的共识机制。例如,区块链节点之间可以实现区块粒度的共识机制,比如在节点(例如某个独特的节点)产生一个区块后,如果产生的这个区块得到其它节点的认可,其它节点记录相同的区块。再例如,区块链节点之间可以实现交易粒度的共识机制,比如在节点(例如某个独特的节点)获取一笔区块链交易后,如果这笔区块链交易得到其他节点的认可,认可该区块链 交易的各个节点可以分别将该区块链交易添加至自身维护的最新区块中,并且最终能够确保各个节点产生相同的最新区块。共识机制是区块链节点就区块信息(或称区块数据)达成全网一致共识的机制,可以保证最新区块被准确添加至区块链。当前主流的共识机制包括:工作量证明(Proof of Work,POW)、股权证明(Proof of Stake,POS)、委任权益证明(Delegated Proof of Stake,DPOS)、实用拜占庭容错(Practical Byzantine Fault Tolerance,PBFT)算法,HoneyBadgerBFT算法等。One of the decentralized features of blockchain technology that distinguishes it from traditional technologies is that bookkeeping is performed on each node, or called distributed bookkeeping, rather than traditional centralized bookkeeping. In order for the blockchain system to become a decentralized, honest and credible system that is difficult to break, open, and cannot be tampered with data records, it is necessary to make distributed data records safe, clear, and irreversible in the shortest possible time. In different types of blockchain networks, in order to maintain the consistency of the ledger in each node that records the ledger, a consensus algorithm is usually used to ensure it, that is, the aforementioned consensus mechanism. For example, a block-granularity consensus mechanism can be implemented between blockchain nodes. For example, after a node (such as a unique node) generates a block, if the generated block is recognized by other nodes, other nodes record the same block. For another example, a consensus mechanism of transaction granularity can be implemented between blockchain nodes. For example, after a node (such as a unique node) obtains a blockchain transaction, if the blockchain transaction is recognized by other nodes, Each node that approves the blockchain transaction can add the blockchain transaction to the latest block maintained by itself, and finally can ensure that each node generates the same latest block. The consensus mechanism is a mechanism for blockchain nodes to reach a consensus on block information (or block data) in the entire network, which can ensure that the latest block is accurately added to the blockchain. The current mainstream consensus mechanisms include: Proof of Work (POW), Proof of Stake (POS), Delegated Proof of Stake (DPOS), Practical Byzantine Fault Tolerance (PBFT) ) algorithm, HoneyBadgerBFT algorithm, etc.
由于区块链网络的去中心化特性,使得区块链网络中的所有区块链节点均会维护相同的区块数据,无法满足部分节点的特殊需求。以联盟链为例,所有联盟成员(即联盟内的节点成员)可以组成一区块链网络,所有联盟成员在该区块链网络中分别存在对应的区块链节点,并可以通过对应的区块链节点获得该区块链网络上发生的所有交易和相关数据。但在一些情况下,可能存在部分联盟成员希望完成一些具有保密需求的交易,这些联盟成员既希望这些交易能够在区块链上存证或借助于区块链技术的其他优势,又能够避免其他联盟成员查看到这些交易和相关数据。虽然这些联盟成员可以额外组建一新的区块链网络,其建立方式与上述包含所有联盟成员的区块链网络类似,但是从头开始建立一条新的区块链网络需要消耗大量的资源,且无论是该区块链网络的建立过程或是建成后的配置过程都非常耗时。联盟成员之间的需求往往是临时的或者具有一定的时效性,使得新建的区块链网络很快就会由于需求消失而失去存在的意义,从而进一步增加了上述区块链网络的建链成本。而联盟成员之间的需求经常会变化,而每一需求所对应的联盟成员也往往不同,因而每当联盟成员发生变化时就可能需要组建一新的区块链网络,从而造成资源和时间的大量浪费。Due to the decentralized nature of the blockchain network, all blockchain nodes in the blockchain network will maintain the same block data, which cannot meet the special needs of some nodes. Taking the consortium chain as an example, all consortium members (that is, node members in the consortium) can form a blockchain network, and all consortium members have corresponding blockchain nodes in the blockchain network, and can pass the corresponding zone Block chain nodes obtain all transactions and related data that occur on the block chain network. However, in some cases, there may be some alliance members who want to complete some transactions that require confidentiality. These alliance members hope that these transactions can be stored on the blockchain or take advantage of other advantages of blockchain technology, and can avoid other transactions. Affiliate members see these transactions and related data. Although these alliance members can additionally form a new blockchain network, the establishment method is similar to the above-mentioned blockchain network that includes all alliance members, but building a new blockchain network from scratch requires a lot of resources, and regardless of The establishment process of the blockchain network or the configuration process after completion is very time-consuming. The needs among alliance members are often temporary or have a certain timeliness, so that the newly built blockchain network will soon lose the meaning of existence due to the disappearance of demand, thus further increasing the chain construction cost of the above-mentioned blockchain network . However, the needs of alliance members often change, and the alliance members corresponding to each demand are often different. Therefore, whenever the alliance members change, it may be necessary to form a new blockchain network, resulting in resource and time constraints. A lot of waste.
为此,可以将已组建的区块链网络作为区块链主网,并在该区块链主网的基础上组建区块链子网。那么,在诸如上述的联盟链场景下,联盟成员可以在已经参与区块链主网的情况下,基于自身需求而在区块链主网的基础上组建所需的区块链子网。由于区块链子网是在区块链主网的基础上所建立,使得区块链子网的组建过程相比于完全独立地组建一条区块链网络,所消耗的资源和所需的耗时等都极大地降低,灵活性极高。To this end, the established blockchain network can be used as the blockchain main network, and a blockchain subnet can be formed on the basis of the blockchain main network. Then, in the consortium chain scenario such as the one mentioned above, the consortium members can build the required blockchain subnet based on their own needs while already participating in the blockchain main network. Since the blockchain subnet is established on the basis of the blockchain main network, the construction process of the blockchain subnet is compared to the completely independent establishment of a blockchain network, the resources consumed and the time required, etc. Both are greatly reduced, and the flexibility is extremely high.
基于区块链主网快捷组建区块链子网的过程如下:区块链主网中的各主网节点分别获取组建区块链子网的交易,所述交易包含所述区块链子网的配置信息,所述配置信息包括节点成员的身份信息。然后,所述区块链主网中的各主网节点分别执行所述交易;其中,当第一主网节点属于所述配置信息所指示的节点成员时,部署第一主网节点的节点设备基于所述交易生成包含所述配置信息的创世块并启动属于所述区块链子网的第一子网节点。The process of quickly establishing a blockchain subnet based on the blockchain main network is as follows: each main network node in the blockchain main network obtains a transaction for establishing a blockchain subnet, and the transaction includes the configuration information of the blockchain subnet , the configuration information includes identity information of node members. Then, each main network node in the blockchain main network respectively executes the transaction; wherein, when the first main network node belongs to the node member indicated by the configuration information, the node device of the first main network node is deployed A genesis block containing the configuration information is generated based on the transaction and a first subnetwork node belonging to the blockchain subnetwork is started.
组建区块链子网的交易可由区块链主网的管理员发起,即仅允许管理员在区块链主网的基础上组建区块链子网,而避免将区块链子网的组建权限开放给普通用户,以防止由此导致的安全性问题。在一些情况下,也可以允许区块链主网的普通用户发起上述组建区块链子网的交易,以满足普通用户的组网需求,使得普通用户能够在管理员不便于发起交易的情况下依然能够快捷地组建区块链子网。The transaction of establishing a blockchain subnet can be initiated by the administrator of the blockchain main network, that is, only the administrator is allowed to establish a blockchain subnet on the basis of the blockchain main network, and avoid opening the establishment authority of the blockchain subnet to Normal users to prevent security issues caused by this. In some cases, ordinary users of the blockchain main network can also be allowed to initiate the above-mentioned transaction of establishing a blockchain subnet to meet the networking needs of ordinary users, so that ordinary users can still initiate transactions when the administrator is inconvenient. It is possible to quickly form a blockchain subnet.
以图4所示为例,区块链主网为subnet0,该subnet0包含的区块链节点为nodeA、nodeB、nodeC、nodeD和nodeE等。假定nodeA、nodeB、nodeC和nodeD希望组建一区块链子网:如果nodeA为管理员且仅允许管理员发起组建区块链子网的交易,那么可由nodeA向subnet0发起上述组建区块链子网的交易;如果nodeE为管理员且仅允许管理员发起组建区块链子网的交易,那么nodeA~nodeD需要向nodeE进行请求,使得nodeE向subnet0发起上述组建区块链子网的交易;如果nodeE为管理员但允许普通用户发起组建区块链子网的交易,那么nodeA~nodeE均可以向subnet0发起上述组建区块链子网的交易。当然,不论是管理员或者普通用户,发起组建区块链子网的交易的区块链节点并不一定参与所组建的区块链子网,比如虽然最终由nodeA、nodeB、nodeC和nodeD组建区块链子网,但可由nodeE向subnet0发起上述组建区块链子网的交易,而并不一 定由nodeA~nodeD来发起该组建区块链子网的交易。Taking Figure 4 as an example, the blockchain main network is subnet0, and the blockchain nodes contained in subnet0 are nodeA, nodeB, nodeC, nodeD, and nodeE. Assume that nodeA, nodeB, nodeC and nodeD want to form a blockchain subnet: if nodeA is an administrator and only allows the administrator to initiate a transaction to form a blockchain subnet, then nodeA can initiate the above-mentioned transaction to form a blockchain subnet to subnet0; If nodeE is an administrator and only allows the administrator to initiate the transaction of establishing a blockchain subnet, then nodeA~nodeD needs to make a request to nodeE, so that nodeE initiates the above transaction of establishing a blockchain subnet to subnet0; if nodeE is an administrator but allows Ordinary users initiate a transaction to establish a blockchain subnet, then nodeA~nodeE can initiate the above transaction to subnet0 to establish a blockchain subnet. Of course, whether it is an administrator or an ordinary user, the blockchain node that initiates the transaction to form a blockchain subnet does not necessarily participate in the established blockchain subnet. network, but nodeE can initiate the above-mentioned transaction of establishing a blockchain subnet to subnet0, and not necessarily nodeA~nodeD initiate the transaction of establishing a blockchain subnet.
在区块链主网的基础上组建区块链子网时,容易理解的是,会使得该区块链子网与区块链主网之间存在逻辑上的层次关系。比如在图4所示的subnet0上组建区块链子网subnet1时,可以认为subnet0处于第一层、subnet1处于第二层,subnet0为subnet1的父网,subnet1为subnet0的子网。并且区块链子网也可以组建对应的区块链子网,例如可以在图4中subnet1的基础上进一步组建另一区块链子网subnet3,此时可以认为subnet处于第三层,subnet1为subnet3对应的父网,subnet3为subnet1的子网,而subnet3则为subnet0的孙子网,同样的,subnet3仍然可以在其基础上新的组建区块链子网,使得各区块链网络之间构成这种多层次树形结构,而在本说明书中,任一区块链网络是由其对应的父网所管理,也即由组建该任一区块链网络的区块链网络所管理,因此在如图4这种由以区块链主网为根结点(根结点的层级最低)、各个区块链子网分别为其他结点的区块链网络树形系统中,任一结点代表的区块链子网由其父结点对应的区块链网络所管理,而作为特例,区块链主网为底层区块链网络时,区块链主网由区块链主网自身进行管理。本说明书中的区块链主网可以为底层区块链网络,底层区块链网络是指并非在其他区块链网络的基础上组建的区块链子网,因此除该区块链主网以外不存在其他区块链网络能够对区块链主网进行管理,比如图4中的subnet0可以认为属于底层区块链网络类型的区块链主网,subnet0管理subnet0自身,当然,区块链主网也可以为其他区块链网络的子网,本说明书对此不作任何限制。上述区块链网络树形系统通过父结点管理对应子结点的方式,实现了逐层管理,降低了区块链主网的管理压力,同时避免向下层网络暴露上层网络的子网信息,从而实现各级网络的隐秘管理。When a blockchain subnet is established on the basis of the blockchain main network, it is easy to understand that there will be a logical hierarchical relationship between the blockchain subnet and the blockchain main network. For example, when building a blockchain subnet subnet1 on subnet0 shown in Figure 4, it can be considered that subnet0 is in the first layer, subnet1 is in the second layer, subnet0 is the parent network of subnet1, and subnet1 is the subnet of subnet0. And the blockchain subnet can also form a corresponding blockchain subnet. For example, another blockchain subnet subnet3 can be further established on the basis of subnet1 in Figure 4. At this time, it can be considered that the subnet is in the third layer, and subnet1 is the corresponding subnet3. The parent network, subnet3 is the subnet of subnet1, and subnet3 is the grandson of subnet0. Similarly, subnet3 can still build a new blockchain subnet based on it, so that this multi-level tree can be formed between blockchain networks In this specification, any blockchain network is managed by its corresponding parent network, that is, it is managed by the blockchain network that forms any blockchain network. Therefore, as shown in Figure 4 A block chain subnet represented by any node in a block chain network tree system with the block chain main network as the root node (the root node has the lowest level) and each block chain subnet as other nodes The network is managed by the blockchain network corresponding to its parent node, and as a special case, when the blockchain main network is the underlying blockchain network, the blockchain main network is managed by the blockchain main network itself. The blockchain main network in this specification can be the underlying blockchain network. The underlying blockchain network refers to a blockchain subnet that is not established on the basis of other blockchain networks. Therefore, in addition to the blockchain main network There is no other blockchain network that can manage the blockchain main network. For example, subnet0 in Figure 4 can be considered as the blockchain main network of the underlying blockchain network type, and subnet0 manages subnet0 itself. Of course, the blockchain main network The network can also be a subnet of other blockchain networks, and this specification does not make any restrictions on this. The above-mentioned blockchain network tree system realizes layer-by-layer management through the parent node management of corresponding child nodes, which reduces the management pressure of the blockchain main network and avoids exposing the subnet information of the upper network to the lower network. In order to realize the secret management of the network at all levels.
上述组建区块链子网的交易在被发送至区块链主网后,由区块链主网内的共识节点进行共识,并在通过共识后由各主网节点执行该交易,以完成区块链子网的组建。共识过程取决于所采用的共识机制,譬如上文所述的任一共识机制,本说明书并不对此进行限制。After the above-mentioned transaction for establishing a blockchain subnet is sent to the blockchain main network, the consensus nodes in the blockchain main network will conduct a consensus, and after the consensus is passed, each main network node will execute the transaction to complete the block The formation of the chain subnet. The consensus process depends on the adopted consensus mechanism, such as any consensus mechanism mentioned above, which is not limited in this description.
通过在上述组建区块链子网的交易中包含配置信息,该配置信息可以用于对所组建的区块链子网进行配置,使得组建的区块链子网符合组网需求。例如,通过在配置信息中包含节点成员的身份信息,可以指定组建的区块链子网包含哪些区块链节点。By including the configuration information in the above-mentioned transaction of establishing the blockchain subnet, the configuration information can be used to configure the established blockchain subnet so that the established blockchain subnet meets the networking requirements. For example, by including the identity information of node members in the configuration information, it is possible to specify which blockchain nodes are included in the established blockchain subnet.
节点成员的身份信息可以包括节点的公钥,或者采用节点ID等其他能够表征节点身份的信息,本说明书并不对此进行限制。以公钥为例,每个区块链节点都存在对应的一组或多组公私钥对,由区块链节点持有私钥而公钥被公开且唯一对应于该私钥,因而可以通过公钥来表征相应区块链节点的身份。因此,对于希望作为区块链子网的节点成员的区块链节点,可以将这些区块链节点的公钥添加至上述组建区块链子网的交易中,以作为上述节点成员的身份信息。The identity information of the node members may include the public key of the node, or other information that can represent the identity of the node such as the node ID, which is not limited in this description. Taking the public key as an example, each blockchain node has one or more sets of corresponding public-private key pairs. The blockchain node holds the private key and the public key is public and uniquely corresponds to the private key. Therefore, it can be passed The public key is used to represent the identity of the corresponding blockchain node. Therefore, for blockchain nodes that want to be node members of the blockchain subnet, the public keys of these blockchain nodes can be added to the above-mentioned transaction of forming the blockchain subnet as the identity information of the above-mentioned node members.
第一主网节点可以为区块链主网上属于配置信息所指示的节点成员的区块链节点。在组建区块链子网时,并非由第一主网节点直接加入区块链子网、成为其节点成员,而是需要由用于部署该第一主网节点的节点设备生成第一子网节点,并由第一子网节点成为区块链子网中的节点成员。第一主网节点和第一子网节点对应于同一个区块链成员,比如在联盟链场景下对应于同一联盟链成员,但第一主网节点属于区块链主网、第一子网节点属于区块链子网,使得该区块链成员可以分别参与到区块链主网和区块链子网的交易中;并且,由于区块链主网和区块链子网属于相互独立的两个区块链网络,使得第一主网节点生成的区块与第一子网节点生成的区块分别存入所述节点设备上的不同存储(采用的存储譬如可以为数据库),实现了第一主网节点与第一子网节点分别使用的存储之间的相互隔离,因而区块链子网所产生的数据仅会在区块链子网的节点成员之间同步,使得仅参与了区块链主网的区块链成员无法获得区块链子网上产生的数据,实现了区块链主网与区块链子网之间的数据隔离,满足了部分区块链成员(即参与区块链子网的区块链成员)之间的交易需求。The first main network node may be a blockchain node on the blockchain main network that is a node member indicated by the configuration information. When building a blockchain subnet, instead of the first main network node directly joining the blockchain subnet and becoming its node member, the first subnet node needs to be generated by the node device used to deploy the first main network node, And the first subnet node becomes a node member in the blockchain subnet. The first main network node and the first subnet node correspond to the same blockchain member, for example, in the alliance chain scenario, they correspond to the same alliance chain member, but the first main network node The node belongs to the blockchain subnet, so that the blockchain members can participate in the transactions of the blockchain main network and the blockchain subnet respectively; and, since the blockchain main network and the blockchain subnet belong to two independent Blockchain network, so that the blocks generated by the first main network node and the blocks generated by the first subnet node are respectively stored in different storages on the node device (the storage used can be a database, for example), realizing the first The storage used by the main network node and the first subnet node is isolated from each other, so the data generated by the blockchain subnet will only be synchronized among the node members of the blockchain subnet, so that only those who participate in the blockchain main The blockchain members of the network cannot obtain the data generated on the blockchain subnet, which realizes the data isolation between the blockchain main network and the blockchain subnet, and satisfies the requirements of some blockchain members (that is, the districts participating in the blockchain subnet). Transaction requirements between blockchain members).
可见,第一主网节点和第一子网节点是在逻辑上划分出来的区块链节点,而从物理设备的角度来说,相当于上述部署了第一主网节点和第一子网节点的节点设备同时参与了区块链主网和区块链子网。由于区块链主网与区块链子网之间相互独立,使得这两个区块链网络的身份体系也相互独立,因而即便第一主网节点和第一子网节点可以采用完全相同的公钥,仍然应当将两者视为不同的区块链节点。譬如在图4中,subnet0中的nodeA相当于第一主网节点,而部署该nodeA的节点设备生成了属于subnet1的nodeA1,该nodeA1相当于第一子网节点。可见,由于身份体系相互独立,所以即便第一子网节点所采用的公钥区别于第一主网节点,也不影响本说明书方案的实施。It can be seen that the first main network node and the first subnet node are logically divided blockchain nodes, and from the perspective of physical equipment, it is equivalent to deploying the first main network node and the first subnet node The node devices participate in the blockchain main network and the blockchain subnet at the same time. Since the blockchain main network and the blockchain subnet are independent of each other, the identity systems of the two blockchain networks are also independent of each other, so even if the first main network node and the first subnet node can use exactly the same public key, the two should still be considered as different blockchain nodes. For example, in FIG. 4 , nodeA in subnet0 is equivalent to the first main network node, and the node device deploying the nodeA generates nodeA1 belonging to subnet1, and the nodeA1 is equivalent to the first subnet node. It can be seen that since the identity systems are independent of each other, even if the public key used by the first subnet node is different from that of the first main network node, it will not affect the implementation of the scheme in this specification.
当然,区块链子网的节点成员并不一定只是区块链主网的部分节点成员。在一些情况下,区块链子网的节点成员可以与区块链主网的节点成员完全一致,此时所有的区块链成员都可以获得区块链主网和区块链子网上的数据,但是区块链主网与区块链子网所产生的数据依然可以相互隔离,比如可以通过在区块链主网上实现一类业务、在区块链子网上实现另一类业务,从而可以使得这两类业务分别产生的业务数据之间相互隔离。Of course, the node members of the blockchain subnet are not necessarily only part of the node members of the blockchain main network. In some cases, the node members of the blockchain subnet can be completely consistent with the node members of the blockchain main network. At this time, all blockchain members can obtain the data on the blockchain main network and the blockchain subnet, but The data generated by the blockchain main network and the blockchain subnet can still be isolated from each other. For example, by implementing one type of business on the blockchain main network and another type of business on the blockchain subnet, the two types of The business data generated by the business are isolated from each other.
除了上述的节点成员的身份信息之外,配置信息还可以包括下述至少之一:所述区块链子网的网络标识、所述区块链子网的管理员的身份信息、针对区块链平台代码的属性配置等,本说明书并不对此进行限制。网络标识用于唯一表征该区块链子网,因而该区块链子网的网络标识应当区别于区块链主网和该区块链主网上组建的其他区块链子网。区块链子网的管理员的身份信息,譬如可以为作为管理员的节点成员的公钥;其中,区块链主网与区块链子网的管理员可以相同,也可以不同。In addition to the above-mentioned identity information of node members, the configuration information may also include at least one of the following: the network identifier of the blockchain subnet, the identity information of the administrator of the blockchain subnet, the The attribute configuration of the code, etc., is not limited in this manual. The network identifier is used to uniquely represent the blockchain subnet, so the network identifier of the blockchain subnet should be distinguished from the blockchain main network and other blockchain subnets formed on the blockchain main network. The identity information of the administrator of the blockchain subnet can be, for example, the public key of the node member who is the administrator; the administrators of the blockchain main network and the blockchain subnet can be the same or different.
通过区块链主网来组建区块链子网的优势之一,就是由于生成第一子网节点的节点设备上已经部署了第一主网节点,因而可以将第一主网节点所使用的区块链平台代码复用在第一子网节点上,免去了区块链平台代码的重复部署,极大地提高了区块链子网的组建效率。那么,如果配置信息中未包含针对区块链平台代码的属性配置,第一子网节点可以复用第一主网节点上采用的属性配置;如果配置信息中包含了针对区块链平台代码的属性配置,第一子网节点可以采用该属性配置,使得第一子网节点所采用的属性配置不受限于第一主网节点的属性配置、与第一主网节点无关。针对区块链平台代码的属性配置可以包括下述至少之一:代码版本号、是否需要共识、共识算法类型、区块大小等,本说明书并不对此进行限制。One of the advantages of building a blockchain subnet through the blockchain mainnet is that since the first mainnet node has already been deployed on the node device that generates the first subnetwork node, the area used by the first mainnet node can be The block chain platform code is reused on the first subnet node, which eliminates the repeated deployment of the block chain platform code and greatly improves the efficiency of the block chain subnet. Then, if the configuration information does not include the attribute configuration for the blockchain platform code, the first subnet node can reuse the attribute configuration adopted on the first main network node; if the configuration information includes the attribute configuration for the blockchain platform code attribute configuration, the first subnetwork node can adopt the attribute configuration, so that the attribute configuration adopted by the first subnetwork node is not limited to the attribute configuration of the first main network node, and has nothing to do with the first main network node. The attribute configuration for the blockchain platform code can include at least one of the following: code version number, whether consensus is required, consensus algorithm type, block size, etc., which are not limited in this specification.
组建区块链子网的交易包括调用合约的交易。该交易中可以指明被调用的智能合约的地址、调用的方法和传入的参数。例如,调用的合约可以为前述的创世合约或系统合约,调用的方法可以为组建区块链子网的方法,传入的参数可以包括上述的配置信息。在一实施例中,该交易可以包含如下信息:Transactions that form blockchain subnets include transactions that call contracts. The transaction can specify the address of the called smart contract, the method called and the parameters passed in. For example, the invoked contract can be the aforementioned genesis contract or system contract, the invoked method can be a method for building a blockchain subnet, and the incoming parameters can include the above-mentioned configuration information. In one embodiment, the transaction may contain the following information:
from:Administratorfrom: Administrator
to:Subnetto: Subnet
method:AddSubnet(string)method: AddSubnet(string)
string:genesisstring: genesis
其中,from字段为该交易的发起方的信息,譬如Administrator表明该发起方为管理员;to字段为被调用的智能合约的地址,譬如该智能合约可以为Subnet合约,则to字段具体为该Subnet合约的地址;method字段为调用的方法,譬如在Subnet合约中用于组建区块链子网的方法可以为AddSubnet(string),而string为AddSubnet()方法中的参数,上述示例中通过genesis表征该参数的取值,该genesis具体为前述的配置信息。Among them, the from field is the information of the initiator of the transaction. For example, Administrator indicates that the initiator is an administrator; the to field is the address of the called smart contract. For example, the smart contract can be a Subnet contract, and the to field is specifically the Subnet The address of the contract; the method field is the calling method. For example, the method used to build a blockchain subnet in the Subnet contract can be AddSubnet(string), and string is the parameter in the AddSubnet() method. In the above example, genesis is used to represent the The value of the parameter, the genesis is specifically the aforementioned configuration information.
以Subnet0上的节点nodeA~nodeE执行调用Subnet合约中AddSubnet()方法的交易为例。在交易通过共识后,nodeA~nodeE分别执行AddSubnet()方法并传入配置信息,得到相应的执行结果。Take nodes nodeA~nodeE on Subnet0 executing a transaction calling the AddSubnet() method in the Subnet contract as an example. After the transaction passes the consensus, nodeA~nodeE respectively execute the AddSubnet() method and pass in the configuration information to obtain the corresponding execution results.
合约的执行结果可以包括所述配置信息,该执行结果可以处于前文所述的收据中,该收据中可以包含与执行AddSubnet()方法相关的event,即组网事件。组网事件的topic 可以包含预定义的组网事件标识,以区别于其他的事件。譬如在与执行AddSubnet()方法相关的event中,topic的内容为关键词subnet,且该关键词区别于其他方法所产生event中的topic。那么,nodeA~nodeE通过监听生成的收据中各个event所含的topic,可以在监听到包含关键词subnet的topic的情况下,确定监听到与执行AddSubnet()方法相关的event,即组网事件。例如,收据中的event如下:The execution result of the contract may include the configuration information, and the execution result may be included in the above-mentioned receipt, which may include an event related to the execution of the AddSubnet() method, that is, a networking event. The topic of networking events can contain predefined networking event identifiers to distinguish them from other events. For example, in the event related to the execution of the AddSubnet() method, the content of the topic is the keyword subnet, and this keyword is different from the topic in the event generated by other methods. Then, by monitoring the topics contained in each event in the generated receipt, nodeA~nodeE can determine to monitor the event related to the execution of the AddSubnet() method, that is, the networking event, when the topic containing the keyword subnet is monitored. For example, the event in the receipt is as follows:
Event:Event:
[topic:other][data][topic:other][data]
[topic:subnet][data][topic:subnet][data]
...... …
那么,nodeA~nodeE在监听到第1条event时,由于所含topic的内容为other,确定该event与AddSubnet()方法无关;以及,nodeA~nodeE在监听到第2条event时,由于所含topic的内容为subnet,确定该event与AddSubnet()方法相关,并进而读取该event对应的data字段,该data字段包含上述的配置信息。以配置信息包括区块链子网的节点成员的公钥为例,data字段的内容例如可以包括:Then, when nodeA~nodeE listens to the first event, because the content of the included topic is other, it is determined that the event has nothing to do with the AddSubnet() method; and, when nodeA~nodeE listens to the second event, because the content of the included The content of the topic is subnet, determine that the event is related to the AddSubnet() method, and then read the data field corresponding to the event, which contains the above configuration information. Taking the configuration information including the public key of the node member of the blockchain subnet as an example, the content of the data field may include, for example:
{subnet1;{subnet1;
nodeA的公钥,nodeA的IP、nodeA的端口号…;The public key of nodeA, the IP of nodeA, the port number of nodeA...;
nodeB的公钥,nodeB的IP、nodeB的端口号…;public key of nodeB, IP of nodeB, port number of nodeB...;
nodeC的公钥,nodeC的IP、nodeC的端口号…;The public key of nodeC, the IP of nodeC, the port number of nodeC...;
nodeD的公钥,nodeD的IP、nodeD的端口号…;The public key of nodeD, the IP of nodeD, the port number of nodeD...;
}}
其中,subnet1为希望创建的区块链子网的网络标识。区块链主网中的各个区块链节点可以记录该区块链主网上已创建的所有区块链子网的网络标识,或者与这些区块链子网相关的其他信息,这些信息譬如可以维护在上述的Subnet合约中,具体可以对应于该Subnet合约所含的一个或多个合约状态的取值。那么,nodeA~nodeE可以根据记录的已创建的所有区块链子网的网络标识,确定上述的subnet1是否已经存在;如果不存在,说明subnet1是当前需要创建的新区块链子网,如果存在则说明subnet1已经存在。Among them, subnet1 is the network identifier of the blockchain subnet you want to create. Each blockchain node in the blockchain main network can record the network identifiers of all blockchain subnets that have been created on the blockchain main network, or other information related to these blockchain subnets, such information can be maintained in In the above-mentioned Subnet contract, it may specifically correspond to the values of one or more contract states included in the Subnet contract. Then, nodeA~nodeE can determine whether the above-mentioned subnet1 already exists according to the recorded network identifiers of all blockchain subnets that have been created; if it does not exist, it means that subnet1 is a new blockchain subnet that needs to be created currently, and if it exists, it means that subnet1 already exists.
除了采用希望创建的新的区块链子网的网络标识之外,还可以采用预定义的新建网络标识,该新建网络标识表明相应的组网事件用于组建新的区块链子网。例如,可以将上述的subnet1替换为newsubnet,该newsubnet为预定义的新建网络标识,nodeA~nodeE在识别到data字段包含newsubnet时,即可确定包含该newsubnet的event为组网事件,需要创建新的区块链子网。In addition to adopting the network identifier of the new blockchain subnet you want to create, you can also use a predefined new network identifier, which indicates that the corresponding networking event is used to form a new blockchain subnet. For example, the above subnet1 can be replaced with newsubnet, which is a predefined new network identifier. When nodeA~nodeE recognizes that the data field contains newsubnet, they can determine that the event containing this newsubnet is a networking event, and a new one needs to be created. Blockchain subnet.
除了网络标识subnet1之外,上述data字段中还包含各个节点成员的身份信息等内容。部署第一主网节点的节点设备可以监听生成的收据,并在监听到所述组网事件且所述组网事件的内容表明第一主网节点属于所述节点成员的情况下,由部署第一主网节点的节点设备获取所述组网事件包含的配置信息或创世块。例如,nodeA~nodeE在确定subnet1是需要新组建的区块链子网的情况下,会进一步识别data字段中包含的节点成员的身份信息,以确定自身的处理方式。比如,nodeA~nodeD会发现在data字段包含自身的公钥、IP地址和端口号等身份信息,假定nodeA~nodeD分别部署在节点设备1~4上,以nodeA和节点设备1为例:nodeA会触发节点设备1,使得节点设备1基于上述的消息机制从data字段获得配置信息并生成包含该配置信息的创世块,且节点设备1会在本地部署nodeA1,进而由nodeA1加载生成的创世块,从而形成为subnet1中的1个节点成员;类似地,nodeB会触发节点设备2生成nodeB1、nodeC会触发节点设备3生成nodeC1、nodeD会触发节点设备4生成nodeD1。以及,nodeE会发现data字段包含的身份信息与自身均不匹配,假定nodeE部署在节点设备5上,那么该节点设备5不会根据data字段中的配置信息生成创世块,也不会生成subnet1中的节点。In addition to the network identifier subnet1, the above data field also includes identity information of each node member and so on. The node device deploying the first main network node can monitor the generated receipt, and when the networking event is monitored and the content of the networking event indicates that the first main network node belongs to the node member, the deployment second A node device of a main network node obtains the configuration information or the genesis block included in the networking event. For example, nodeA~nodeE will further identify the identity information of the node members contained in the data field in order to determine their own processing methods when they determine that subnet1 is a blockchain subnet that needs to be newly established. For example, nodeA~nodeD will find that the data field contains their own identity information such as their public key, IP address, and port number. Assume that nodeA~nodeD are deployed on node devices 1~4 respectively. Taking nodeA and node device 1 as an example: nodeA will Trigger node device 1, so that node device 1 obtains configuration information from the data field based on the above-mentioned message mechanism and generates a genesis block containing the configuration information, and node device 1 will deploy nodeA1 locally, and then nodeA1 will load the generated genesis block , thus forming a node member in subnet1; similarly, nodeB will trigger node device 2 to generate nodeB1, nodeC will trigger node device 3 to generate nodeC1, and nodeD will trigger node device 4 to generate nodeD1. And, nodeE will find that the identity information contained in the data field does not match itself, assuming that nodeE is deployed on node device 5, then the node device 5 will not generate a genesis block based on the configuration information in the data field, nor will it generate subnet1 nodes in .
如前所述,第一主网节点与第一子网节点并不一定采用相同的身份信息。因此,在上述实施例中,data字段中可以包含预先为nodeA1~nodeD1生成的身份信息,且区别于 nodeA~nodeD的身份信息。仍以nodeA为例,nodeA如果在data字段中发现了nodeA1的身份信息,那么nodeA会触发节点设备1生成创世块、部署nodeA1,并由nodeA1加载该创世块;nodeB~nodeD的处理方式类似,此处不再一一赘述。As mentioned above, the first main network node and the first subnet node do not necessarily use the same identity information. Therefore, in the above embodiment, the data field may contain identity information generated in advance for nodeA1-nodeD1, which is different from the identity information of nodeA-nodeD. Still taking nodeA as an example, if nodeA finds the identity information of nodeA1 in the data field, then nodeA will trigger node device 1 to generate a genesis block, deploy nodeA1, and nodeA1 will load the genesis block; nodeB~nodeD are processed in a similar way , which will not be repeated here.
除了配置信息之外,合约的执行结果可以包括创世块。换言之,除了可以在data字段中包含配置信息,还可以直接在执行合约调用的过程中生成包含配置信息的创世块,从而将创世块包含于data字段中,那么对于上述的nodeA~nodeD而言,相应的节点设备1~4可以通过消息机制直接从data字段获得创世块,而无需自行生成,可以提升对nodeA1~nodeD1的部署效率。In addition to configuration information, the execution result of the contract can include the genesis block. In other words, in addition to including configuration information in the data field, you can also directly generate a genesis block containing configuration information in the process of executing the contract call, so that the genesis block is included in the data field, then for the above nodeA ~ nodeD and In other words, the corresponding node devices 1-4 can directly obtain the genesis block from the data field through the message mechanism without generating it by themselves, which can improve the deployment efficiency of nodeA1-nodeD1.
在本说明书中,组建区块链子网的交易可以并非是调用智能合约的交易,使得不支持智能合约的区块链网络也可以实现本说明书的技术方案,从而在区块链主网的基础上快捷地创建出区块链子网。例如,可以预先定义一组网交易类型标识,当交易包含该组网交易类型标识时,就表明该交易用于组建新的区块链子网,即该交易为组建区块链子网的交易。区块链平台代码可以包含相关的用于组建区块链子网的处理逻辑,使得运行该区块链平台代码的第一主网节点在执行交易时,如果发现该交易中包含上述的组网交易类型标识,且第一主网节点属于该交易中的配置信息所指示的节点成员,可以基于上述处理逻辑来触发部署第一主网节点的节点设备生成包含该配置信息的创世块并启动第一子网节点,由第一子网节点加载该创世块,以形成为区块链子网中的区块链节点。In this specification, the transaction of establishing a blockchain subnet may not be a transaction that calls a smart contract, so that a blockchain network that does not support smart contracts can also implement the technical solution of this specification, so that on the basis of the blockchain main network Quickly create a blockchain subnet. For example, a group of network transaction type identifiers can be pre-defined, and when the transaction contains the network transaction type identifier, it indicates that the transaction is used to form a new blockchain subnet, that is, the transaction is a transaction to form a blockchain subnet. The blockchain platform code can contain relevant processing logic for building a blockchain subnet, so that when the first main network node running the blockchain platform code executes a transaction, if it finds that the transaction contains the above-mentioned networking transaction type identification, and the first main network node belongs to the node member indicated by the configuration information in the transaction, based on the above processing logic, the node device deploying the first main network node can be triggered to generate a genesis block containing the configuration information and start the first A subnetwork node, the first subnetwork node loads the genesis block to form a blockchain node in the blockchain subnetwork.
节点设备通过拉起一进程,并在该进程中创建一个实例,由该实例运行区块链平台代码,相当于在该节点设备上部署一区块链节点。对于第一主网节点而言,由节点设备在上述进程中创建第一实例,并由该第一实例运行区块链平台代码而形成。类似地,对于第一子网节点而言,由节点设备在上述进程中创建区别于第一实例的第二实例,并由该第二实例运行区块链平台代码而形成。当第一实例与第二实例位于同一进程时,由于不涉及跨进程交互,可以降低对第一子网节点的部署难度、提高部署效率;当然,第二实例也可能与第一实例分别处于节点设备上的不同进程中,本说明书并不对此进行限制。事实上,本说明书实施例中涉及的任一节点设备上部署的各区块链节点均为运行在所述任一节点设备上的不同的区块链实例,任一节点设备上部署的各区块链节点生成的区块分别存入所述任一节点设备上的不同存储(例如数据库),且任一节点设备部署的各区块链节点分别使用的存储之间相互隔离。The node device pulls up a process and creates an instance in the process, and the instance runs the blockchain platform code, which is equivalent to deploying a blockchain node on the node device. For the first main network node, the node device creates the first instance in the above process, and the first instance runs the blockchain platform code to form. Similarly, for the first subnetwork node, the node device creates a second instance different from the first instance in the above process, and the second instance runs the blockchain platform code to form. When the first instance and the second instance are in the same process, because no cross-process interaction is involved, the difficulty of deploying the first subnet node can be reduced and the deployment efficiency can be improved; of course, the second instance may also be in separate nodes from the first instance In different processes on the device, this specification does not limit this. In fact, each blockchain node deployed on any node device involved in the embodiments of this specification is a different blockchain instance running on any node device, and each blockchain node deployed on any node device The blocks generated by the nodes are respectively stored in different storages (such as databases) on any node device, and the storages used by each blockchain node deployed by any node device are isolated from each other.
通过上述方式,可以在区块链主网上创建出区块链子网。以图4为例,subnet0原本包含nodeA~nodeE,而在subnet0的基础上可以组建出subnet1,该subnet1包含nodeA1~nodeD1,且nodeA与nodeA1、nodeB与nodeB1、nodeC与nodeC1、nodeD与nodeD1分别部署在同一节点设备上。类似地,还可以在subnet0上组建出subnet2或更多的区块链子网,其中subnet2包含nodeA2、nodeB2、nodeC2和nodeE2,且nodeA与nodeA1、nodeA2,nodeB与nodeB1、nodeB2,nodeC与nodeC1,nodeD与nodeD1,nodeE与nodeE2分别部署在同一节点设备上。以及,可以将subnet1、subnet2等作为区块链主网,并在此基础上进一步组建出区块链子网,例如在subnet1的基础上组建出区块链子网subnet3,其过程与subnet1或subnet2的组建相似,仅仅是将区块链主网替换为区块链子网subnet1,此处不再赘述,最后得到subnet3包含nodeA3、nodeB3和nodeC3,使得且nodeA与nodeA1、nodeA2、nodeA3,nodeB与nodeB1、nodeB2、nodeB3,nodeC与nodeC1、nodeC2、nodeC3分别部署在同一节点设备上。Through the above method, a blockchain subnet can be created on the blockchain mainnet. Taking Figure 4 as an example, subnet0 originally included nodeA~nodeE, and subnet1 can be built on the basis of subnet0. This subnet1 includes nodeA1~nodeD1, and nodeA and nodeA1, nodeB and nodeB1, nodeC and nodeC1, nodeD and nodeD1 are respectively deployed in on the same node device. Similarly, subnet2 or more blockchain subnets can also be established on subnet0, where subnet2 includes nodeA2, nodeB2, nodeC2 and nodeE2, and nodeA and nodeA1, nodeA2, nodeB and nodeB1, nodeB2, nodeC and nodeC1, nodeD and nodeD1, nodeE and nodeE2 are respectively deployed on the same node device. And, you can use subnet1, subnet2, etc. as the blockchain main network, and further build a blockchain subnet on this basis, for example, build a blockchain subnet subnet3 on the basis of subnet1, and its process is the same as the establishment of subnet1 or subnet2 Similarly, just replace the blockchain main network with the blockchain subnet subnet1, which will not be repeated here, and finally get subnet3 including nodeA3, nodeB3 and nodeC3, so that nodeA and nodeA1, nodeA2, nodeA3, nodeB and nodeB1, nodeB2, nodeB3, nodeC and nodeC1, nodeC2, nodeC3 are respectively deployed on the same node device.
对于通过前述方式建立的任一区块链网络(如上述区块链主网或区块链子网),其上可以部署智能合约,该智能合约的合约代码分布式的运行在构成该区块链网络的各个区块链节点的虚拟机中。在相关技术中,通常由用户或技术人员通过手动编程的方式编写智能合约的合约代码,因此智能合代码标准化程度较低,不利于智能合约的生成以及执行,限制了智能合约的部署及执行效率。For any blockchain network established by the aforementioned method (such as the above-mentioned blockchain main network or blockchain subnet), smart contracts can be deployed on it, and the contract code of the smart contract runs in a distributed manner to form the blockchain In the virtual machines of each blockchain node of the network. In related technologies, the contract code of smart contracts is usually written by users or technicians through manual programming. Therefore, the standardization of smart contract codes is low, which is not conducive to the generation and execution of smart contracts, and limits the deployment and execution efficiency of smart contracts. .
为此,本说明书提出了一种智能合约部署方法。允许用户使用工作流描述语言 (Workflow Description Language,工作流描述语言)对具体业务的工作流进行描述,从而生成该语言编写的任务代码,并通过自动化的编译器对任务代码进行编译,以直接生成可以用于部署的智能合约,从而通过统一的标准化工作流描述语言对工作流进行描述,提升了所生成合约代码的标准化程度;而且使用相对于直接编写合约代码,允许用户使用该语言编写任务代码,并使用编译器根据任务代码自动生成合约代码,有效保证了标准化智能合约的生成效率,也有助于保证合约的执行效率。下面结合实施例对该方法进行详细说明。To this end, this specification proposes a smart contract deployment method. Allows users to describe the workflow of a specific business using a workflow description language (Workflow Description Language), thereby generating task code written in this language, and compiling the task code through an automated compiler to directly generate Smart contracts that can be used for deployment, so as to describe the workflow through a unified standardized workflow description language, which improves the standardization of the generated contract code; and allows users to write task code using this language compared to directly writing contract code , and use the compiler to automatically generate the contract code according to the task code, which effectively ensures the generation efficiency of the standardized smart contract and also helps to ensure the execution efficiency of the contract. The method will be described in detail below in conjunction with the examples.
请参见图5,图5是一示例性实施例提供的一种智能合约部署方法的流程图。如图5所示,该方法可以包括以下步骤:步骤502,用户确定业务对应的工作流。Please refer to FIG. 5, which is a flowchart of a smart contract deployment method provided by an exemplary embodiment. As shown in FIG. 5 , the method may include the following steps: Step 502 , the user determines the workflow corresponding to the service.
用户可以通过绘图、文字描述等多种方式对具体业务涉及到的工作流程进行梳理,从而确定出具体业务的工作流。确定出的工作流可以包括多个待执行任务,各个待执行任务之间的逻辑关系与具体业务的业务逻辑相对应。Users can sort out the workflow involved in a specific business through various methods such as drawing and text description, so as to determine the workflow of a specific business. The determined workflow may include multiple tasks to be performed, and the logical relationship between each task to be performed corresponds to the business logic of a specific business.
例如,不同待执行任务之间可以存在依赖关系,即任务之间按照时间上的串行顺序依次执行,例如第一待执行任务需要第二待执行任务的执行结果作为入参,则第一待执行任务需要在第二待执行任务执行完成后再执行。或者,不同待执行任务之间也可以不存在依赖关系,即任务之间可以按照时间上的并行顺序同时执行,例如第一待执行任务与第二待执行任务的之间并不存在数据上的相互需求,则可以在执行第一待执行任务的同时执行第二待执行任务;当然,也可以在执行第一待执行任务完成后再执行第二待执行任务,或者在执行第二待执行任务完成后再执行第一待执行任务,本说明书实施例对于工作流中各个待执行任务的具体时序关系并不进行限制。For example, there may be a dependency relationship between different tasks to be executed, that is, the tasks are executed sequentially according to the serial order of time. For example, the first task to be executed requires the execution result of the second task to be executed as an input parameter, and the first The execution task needs to be executed after the execution of the second task to be executed is completed. Alternatively, there may be no dependency relationship between different tasks to be executed, that is, the tasks may be executed simultaneously in parallel order in time, for example, there is no data discrepancy between the first task to be executed and the second task to be executed If there is mutual demand, the second task to be executed can be executed while the first task to be executed is executed; of course, the second task to be executed can also be executed after the first task to be executed is completed, or the second task to be executed can be executed The first to-be-executed task is executed after completion, and the embodiment of this specification does not limit the specific timing relationship of each to-be-executed task in the workflow.
步骤504,用户使用工作流描述语言编写描述工作流的任务代码。 Step 504, the user uses the workflow description language to write the task code describing the workflow.
在确定出上述工作流之后,用户可以按照该工作流直接使用工作流描述语言编写任务代码。具体的,可以使用开源的OpenWDL等工作流描述语言编写上述任务代码,当然,也可以使用BPMN语言(Business Process Model and Notation,业务流程建模与标注)等进行任务代码的编写,本说明书实施例对于工作流描述语言的具体形式并不进行限制。因为上述OpenWDL或BPMN语言相对于C++、Bitcoin Script、solidity等智能合约的编程语言而言更简单易懂,而且更便于对工作流进行业务层面的准确描述,因此用户只需要关注具体业务的整体业务流程即可,无需费心于具体业务在智能合约中的底层实现方式,从而使用这类语言编写任务代码有助于减轻用户的使用门槛并提升智能合约的生成效率。After determining the above workflow, the user can directly use the workflow description language to write task codes according to the workflow. Specifically, the above-mentioned task codes can be written using workflow description languages such as open source OpenWDL. Of course, the task codes can also be written using BPMN language (Business Process Model and Notation, business process modeling and labeling). The embodiment of this manual The specific form of the workflow description language is not limited. Because the above-mentioned OpenWDL or BPMN language is simpler and easier to understand than C++, Bitcoin Script, solidity and other smart contract programming languages, and it is easier to accurately describe the workflow at the business level, so users only need to pay attention to the overall business of the specific business The process is enough, and there is no need to worry about the underlying implementation of specific business in the smart contract, so using this language to write task codes can help reduce the user's use threshold and improve the generation efficiency of smart contracts.
步骤506,区块链平台调用编译器根据任务代码生成智能合约。 Step 506, the blockchain platform invokes the compiler to generate a smart contract according to the task code.
用户可以在区块链节点对应的客户端中编写上述任务代码,从而在编写完成后,客户端可以将任务代码自动上传至区块链平台以生成合约代码。或者,用户也可以在离线设备中编写任务代码,并将编写完成的任务代码上传至区块链平台以生成合约代码。又或者,用户还可以在离线设备中编写任务代码,并将编写完成的任务代码在客户端中生成合约代码,进而通过客户端将合约代码部署至区块链平台,以完成智能合约的部署,不再赘述。另外,用户可以使用文本编辑器或者具有代码调试功能的代码编写软件等多种方式进行上述任务代码的编写,本说明书并不对此进行限制。Users can write the above task code in the client corresponding to the blockchain node, so that after the writing is completed, the client can automatically upload the task code to the blockchain platform to generate the contract code. Alternatively, users can also write task codes in offline devices, and upload the completed task codes to the blockchain platform to generate contract codes. Alternatively, users can also write task codes in offline devices, and generate contract codes on the client with the completed task codes, and then deploy the contract codes to the blockchain platform through the client to complete the deployment of smart contracts. No longer. In addition, users can use text editors or code writing software with code debugging functions to write the above task codes, which is not limited in this manual.
其中,区块链平台中可以部署有编译器,该编译器可以用于根据工作流描述语言编写的任务代码生成高级语言编写的合约代码或者直接生成字节码。以工作流描述语言为OpenWDL、合约代码使用C++语言编译为例,因为相关技术中并不存在应用于区块链场景的类似编译器,因此本说明书实施例所述的编译器为发明人自行研发的编译器,用于根据OpenWDL语言编写的任务代码生成C++语言编写的合约代码。具体的,在接收到客户端或用户设备上传的任务代码后,区块链平台可以调用该编译器根据任务代码生成合约代码,从而生成智能合约。Among them, a compiler can be deployed in the blockchain platform, and the compiler can be used to generate contract code written in a high-level language or directly generate bytecode according to the task code written in the workflow description language. Taking the workflow description language as OpenWDL and the contract code compiled in C++ language as an example, because there is no similar compiler applied to blockchain scenarios in related technologies, the compiler described in the embodiments of this manual is developed by the inventor himself Compiler for generating contract code written in C++ language based on task code written in OpenWDL language. Specifically, after receiving the task code uploaded by the client or user equipment, the blockchain platform can call the compiler to generate the contract code according to the task code, thereby generating a smart contract.
可以理解的是,因为任务代码是用户通过工作流描述语言针对工作流编写的,而工 作流往往仅关注业务的逻辑流程和整体框架,因此该任务代码并不包含具体的业务实现方法。而上述编译器在将任务代码编译过程中,可以根据区块链场景下实现具体业务的相关的处理逻辑生成合约代码,如在编译过程中对底层功能进行扩充等,以保证合约代码能够正常运行。例如,在任务代码包含“从数据库A1中读取数据D1”的情况下,编译器生成的合约代码可以包含“访问数据库A1”、“向数据库A1请求获取D1”、“接收数据库A1返回的加密狗的数据D1”、“对接收到的数据D1进行解密和校验”等具体实现流程。显然,上述各实现流程并不需要用户编写在任务代码中,从而用户仅需要关注业务逻辑,而由编译器在编译过程中生成具体实现业务逻辑的合约代码。It is understandable that because the task code is written by the user for the workflow through the workflow description language, and the workflow often only focuses on the logical flow and overall framework of the business, so the task code does not contain specific business implementation methods. In the process of compiling the task code, the above-mentioned compiler can generate the contract code according to the relevant processing logic to realize the specific business in the blockchain scenario, such as expanding the underlying functions during the compilation process, etc., to ensure the normal operation of the contract code . For example, when the task code includes "read data D1 from database A1", the contract code generated by the compiler can include "access database A1", "request D1 from database A1", "receive encrypted data returned by database A1 Dog's data D1", "decrypt and verify the received data D1" and other specific implementation processes. Obviously, the above implementation processes do not require the user to write in the task code, so the user only needs to pay attention to the business logic, and the compiler generates the contract code that specifically implements the business logic during the compilation process.
步骤508,平台将智能合约部署至区块链网络。 Step 508, the platform deploys the smart contract to the blockchain network.
在生成上述合约代码后,区块链平台可以发起一笔用于部署该合约代码的区块链交易,从而区块链网络中的各个区块链节点在执行该交易后,可以在各自节点中部署完成相应的智能合约(即将合约代码作为该智能合约的合约内容)。After generating the above contract code, the blockchain platform can initiate a blockchain transaction for deploying the contract code, so that each blockchain node in the blockchain network can execute the transaction in their respective nodes The corresponding smart contract is deployed (that is, the contract code is used as the contract content of the smart contract).
显然,上述方式生成的合约代码中包含前述工作流的业务逻辑,因此最终部署完成的智能合约在被执行时,能够实现前述工作流的待执行任务,从而实现完成用户指定的具体业务。Obviously, the contract code generated by the above method contains the business logic of the aforementioned workflow, so when the final deployed smart contract is executed, it can realize the tasks to be executed of the aforementioned workflow, thereby completing the specific business specified by the user.
请参见图6,图6是一示例性实施例提供的另一种智能合约部署方法的流程图,该方法可以应用于区块链节点实例(即区块链节点)、区块链节点对应的区块链平台等,下面以区块链平台为例进行说明。如图6所示,该方法可以包括以下步骤:Please refer to Fig. 6, Fig. 6 is a flow chart of another smart contract deployment method provided by an exemplary embodiment, which can be applied to blockchain node instances (that is, blockchain nodes), blockchain nodes corresponding Blockchain platform, etc., the following uses the blockchain platform as an example to illustrate. As shown in Figure 6, the method may include the following steps:
步骤602,获取使用工作流描述语言对工作流进行描述而生成的任务代码。 Step 602, acquiring the task code generated by describing the workflow using the workflow description language.
如前所述,区块链平台可以接收用户使用工作流描述语言对工作流进行描述得到的(即使用工作流描述语言编写的)任务代码,该任务代码可以用于描述工作流中所包含的各个待执行任务及其之间的相互关系等。上述任务代码可以由用户自行手动编写,或者,为减少用户的代码编写工作量以及进一步降低用户的部署合约代码的门槛,区块链平台可以为用户提供预定义的任务模板,从而用户可以在客户端显示的任务界面中通过拖、拉、拽等方式对任务模板进行配置,当然也可以在任务模板的参数配置界面中输入针对任务模板的配置参数。进而,区块链平台可以根据上述任务模板之间的连接关系、时序关系以及各个任务模板的配置参数等配置信息自动生成任务代码。可见,用户只需要根据具体业务对预定义的任务模板进行简单的参数配置,区块链平台即可以自动生成任务代码,从而实现任务代码的一键生成,甚至实现智能合约的一键生成及部署,大大降低了用户的合约部署门槛并提升部署效率。As mentioned above, the blockchain platform can receive the task code obtained by the user to describe the workflow using the workflow description language (that is, written in the workflow description language), and the task code can be used to describe the tasks contained in the workflow. Various tasks to be performed and their interrelationships, etc. The above task codes can be manually written by the user, or, in order to reduce the user's code writing workload and further reduce the user's threshold for deploying contract codes, the blockchain platform can provide users with predefined task templates, so that users can The task template can be configured by dragging, pulling, and dropping in the task interface displayed on the terminal. Of course, the configuration parameters for the task template can also be entered in the parameter configuration interface of the task template. Furthermore, the blockchain platform can automatically generate task codes based on configuration information such as the connection relationship between the above task templates, the timing relationship, and the configuration parameters of each task template. It can be seen that users only need to configure simple parameters for predefined task templates according to specific businesses, and the blockchain platform can automatically generate task codes, thereby realizing one-click generation of task codes, and even one-click generation and deployment of smart contracts , greatly reducing the user's contract deployment threshold and improving deployment efficiency.
步骤604,通过编译器对所述任务代码进行编译,生成用于表征所述工作流的合约代码。In step 604, the task code is compiled by a compiler to generate a contract code for representing the workflow.
如前所述,区块链平台中可以部署有功能插件形式的编译器,因此该平台可以使用编译器对任务代码进行编译得到合约代码。其中,区块链平台可以将上述任务代码编译为由C++、Java、Python等高级语言编写的合约代码。实际上,在智能合约的执行过程中,上述高级语言编写的合约代码需要被进一步编译为字节码才能够被执行,所以为加快智能合约的执行速度,减少执行过程中的编译时长,区块链平台也可以直接将任务代码编译为字节码,并将该字节码作为合约代码。当然,考虑到字节码的可读性较差,因此为保证用户在智能合约生成过程中对于合约代码的充分知悉,区块链平台也可以由先将所述任务代码编译为高级语言编写的代码,再将该高级语言编写的代码进一步编译为字节码,并将字节码作为合约代码。此时,区块链平台可以将上述高级语言编写的代码一并提供给(如发送至客户端显示)用户,以便用户通过查看该代码对任务代码进行修改或调整等,提升生成智能合约的灵活性。As mentioned above, a compiler in the form of a functional plug-in can be deployed in the blockchain platform, so the platform can use the compiler to compile the task code to obtain the contract code. Among them, the blockchain platform can compile the above task codes into contract codes written in high-level languages such as C++, Java, and Python. In fact, during the execution of the smart contract, the contract code written in the above-mentioned high-level language needs to be further compiled into bytecode before it can be executed. Therefore, in order to speed up the execution of the smart contract and reduce the compilation time in the execution process, the block The chain platform can also directly compile the task code into bytecode and use the bytecode as the contract code. Of course, considering the poor readability of the bytecode, in order to ensure that the user is fully aware of the contract code during the generation of the smart contract, the blockchain platform can also compile the task code into a high-level language Code, and then further compile the code written in the high-level language into bytecode, and use the bytecode as the contract code. At this time, the blockchain platform can provide the code written in the above-mentioned high-level language to the user (for example, send it to the client for display), so that the user can modify or adjust the task code by viewing the code, and improve the flexibility of generating smart contracts. sex.
步骤606,向区块链网络发送用于部署所述合约代码的区块链交易,以在所述区块链网络中部署相应的智能合约,所述智能合约用于在被调用时根据所述工作流中各任务结点所定义的业务逻辑向参与所述区块链网络的节点成员分配待执行任务。 Step 606, sending a block chain transaction for deploying the contract code to the block chain network, so as to deploy the corresponding smart contract in the block chain network, and the smart contract is used to be called according to the The business logic defined by each task node in the workflow assigns tasks to be executed to the node members participating in the blockchain network.
以图4所示的区块链网络为例,在区块链主网subnet0中,该网络中各个区块链节点所在的节点设备分别归属于相应的区块链成员。如在subnet0为联盟链的情况下,subnet0中的各区块链节点nodeA、nodeB、nodeC、nodeD、nodeE可以分别对应于不同的联盟链成员。Taking the blockchain network shown in Figure 4 as an example, in the blockchain main network subnet0, the node devices where each blockchain node in the network is located belong to the corresponding blockchain members. For example, when subnet0 is a consortium chain, each blockchain node nodeA, nodeB, nodeC, nodeD, and nodeE in subnet0 can correspond to different consortium chain members respectively.
在生成上述合约代码后,区块链平台可以向区块链网络发送用于部署该合约代码的区块链交易,从而区块链网络中的各个区块链节点可以执行该交易(当然,必要时可以先对该交易进行共识,共识通过的情况下再各自执行),以将包含上述合约代码的智能合约部署至区块链网络。因为上述合约代码根据任务代码生成,而任务代码被使用工作流描述语言描述包含待执行任务的工作流得到,所以该智能合约在被调用时可以根据工作流中各任务结点所定义的业务逻辑向参与区块链网络的节点成员分配待执行任务,以通过智能合约的执行完成待执行任务的执行,从而实现业务逻辑对应的具体业务。After the above contract code is generated, the blockchain platform can send a blockchain transaction for deploying the contract code to the blockchain network, so that each blockchain node in the blockchain network can execute the transaction (of course, if necessary At this time, the transaction can be consensused first, and then executed separately when the consensus is passed), so as to deploy the smart contract containing the above contract code to the blockchain network. Because the above contract code is generated based on the task code, and the task code is obtained by using the workflow description language to describe the workflow containing the tasks to be executed, the smart contract can be invoked according to the business logic defined by each task node in the workflow Assign tasks to be executed to the node members participating in the blockchain network, so as to complete the execution of the tasks to be executed through the execution of smart contracts, so as to realize the specific business corresponding to the business logic.
进一步的,在上述合约代码由高级语言编写的情况下,区块链平台可以将合约代码编译为字节码之后部署该字节码,以减少智能合约的执行等待时长。当然,为减少用户在部署智能合约的等待时长,区块链平台也可以在区块链网络中部署高级语言编写的合约代码,并在部署完成后立即开始将该合约代码编译为字节码,从而通过在执行前预先编译保证智能合约的执行效率。Furthermore, in the case that the above-mentioned contract code is written in a high-level language, the blockchain platform can compile the contract code into bytecode and then deploy the bytecode to reduce the waiting time for smart contract execution. Of course, in order to reduce the waiting time for users to deploy smart contracts, the blockchain platform can also deploy contract code written in a high-level language in the blockchain network, and start compiling the contract code into bytecode immediately after the deployment is completed. Therefore, the execution efficiency of smart contracts is guaranteed by pre-compiling before execution.
可见,本方案允许用户使用工作流描述语言对具体业务的工作流进行描述,从而生成该语言编写的任务代码,并通过自动化的编译器对任务代码进行编译,以直接生成可以用于部署的合约代码,从而通过统一的、标准化的工作流描述语言对工作流进行描述,提升了所生成合约代码的标准化程度;而且相对于直接编写合约代码,允许用户使用该语言编写任务代码,并使用编译器根据任务代码自动生成合约代码,有效提升了标准化智能合约的生成效率,从而有助于保证合约的执行效率。It can be seen that this solution allows users to use a workflow description language to describe the workflow of a specific business, thereby generating task code written in this language, and compiling the task code through an automated compiler to directly generate a contract that can be used for deployment Code, so as to describe the workflow through a unified and standardized workflow description language, which improves the standardization of the generated contract code; and compared with writing contract code directly, users are allowed to use this language to write task code and use the compiler The contract code is automatically generated according to the task code, which effectively improves the generation efficiency of the standardized smart contract, thus helping to ensure the execution efficiency of the contract.
进一步的,在上述智能合约部署完成后,区块链网络中的区块链节点可以响应于区块链交易执行该智能合约。为此,本说明书提出了另一种智能合约部署方法,该方法应用于区块链网络中的区块链节点,下面结合图7对该方法进行详细说明。Further, after the deployment of the above-mentioned smart contract is completed, the blockchain nodes in the blockchain network can execute the smart contract in response to the blockchain transaction. For this reason, this specification proposes another smart contract deployment method, which is applied to the blockchain nodes in the blockchain network. The method will be described in detail below in conjunction with FIG. 7 .
步骤702,响应于接收到的部署合约代码的区块链交易,在所述区块链网络中部署相应的智能合约;所述合约代码由编译器对任务代码进行编译而生成,所述任务代码由工作流描述语言对工作流进行描述而生成。Step 702, in response to the received blockchain transaction for deploying the contract code, deploy the corresponding smart contract in the blockchain network; the contract code is generated by compiling the task code by the compiler, and the task code Generated by describing the workflow in the workflow description language.
步骤704,响应于接收到的调用所述智能合约的区块链交易,根据所述工作流中各任务结点所定义的业务逻辑向参与所述区块链网络的节点成员分配待执行任务。 Step 704, in response to the received blockchain transaction calling the smart contract, assign tasks to be executed to node members participating in the blockchain network according to the business logic defined by each task node in the workflow.
在本实施例中,区块链网络中部署的智能合约可以被任一区块链节点发布的区块链交易调用并执行。如前所述,任务代码由工作流描述语言对工作流进行描述而生成,而合约代码由编译器对任务代码进行编译而生成,所以智能合约中定义有对应于各个待执行任务的工作流,其中,各个待执行任务分别存在相应的任务结点。执行智能合约的过程即为依次执行工作流中定义的各个待执行任务的过程,待执行任务的执行使得智能合约的工作状态按照工作流的预设顺序在各个任务结点之间发生状态迁移。In this embodiment, the smart contracts deployed in the blockchain network can be invoked and executed by blockchain transactions issued by any blockchain node. As mentioned above, the task code is generated by describing the workflow by the workflow description language, and the contract code is generated by compiling the task code by the compiler, so the smart contract defines the workflow corresponding to each task to be executed, Wherein, there are corresponding task nodes for each task to be executed. The process of executing the smart contract is the process of sequentially executing each task to be executed defined in the workflow. The execution of the task to be executed makes the working status of the smart contract transition between each task node according to the preset order of the workflow.
如前所述,部署完成的上述智能合约可以被区块链交易所调用。在一实施例中,区块链节点可以响应于调用智能合约的第一交易,在工作流的处理进度处于第一任务结点之前且第一交易提供的入参使第一任务结点的执行条件被满足的情况下,生成包含第一任务结点所对应第一待执行任务的任务分配事件。其中,上述第一交易用于触发执行智能合约中的第一待执行任务,例如,第一交易调用智能合约后,智能合约可以生成对应于第一待执行任务的任务分配事件,该事件可以被区块链平台的任务调度中心所获取,并根据该事件将第一待执行任务分配至相应的执行方进行处理。As mentioned earlier, the deployed smart contracts above can be invoked by blockchain exchanges. In an embodiment, the block chain node can respond to the first transaction of calling the smart contract, and the processing progress of the workflow is before the first task node and the input parameters provided by the first transaction make the execution of the first task node When the condition is met, a task assignment event including the first task to be executed corresponding to the first task node is generated. Wherein, the above-mentioned first transaction is used to trigger the execution of the first task to be executed in the smart contract. For example, after the first transaction invokes the smart contract, the smart contract can generate a task assignment event corresponding to the first task to be executed. The task dispatching center of the blockchain platform obtains it, and assigns the first task to be executed to the corresponding executor for processing according to the event.
在一实施例中,上述第一任务结点的执行条件可以为第一交易提供的入参的数据格式符合要求。不妨将智能合约中的工作流定义的任务称为“合约任务”,假设第一交易推动工作流开始执行合约任务A,即第一任务结点为合约任务A对应的任务结点A,则 第一交易提供的入参可以为字符串(String)形式的事件类型type,以及字节(Bytes)形式的参数args等。从而,区块链节点可以在判断上述事件类型和参数的数据格式符合被调用方法的指定格式的情况下,确定第一交易提供的入参满足执行条件。可见,若当前时刻工作流的处理进度处于任务结点A之前,则该执行条件被满足可以作为区块链节点生成对应于任务结点A的任务分配事件的触发条件。例如,第一交易调用合约的前述transit方法时,提供的参数ev可以为In an embodiment, the execution condition of the above-mentioned first task node may be that the data format of the input parameter provided by the first transaction meets the requirements. The task defined by the workflow in the smart contract may be called "contract task". Suppose the first transaction pushes the workflow to start executing contract task A, that is, the first task node is the task node A corresponding to contract task A, then the first The input parameters provided by a transaction can be the event type type in the form of a string (String), and the parameter args in the form of bytes (Bytes). Therefore, the block chain node can determine that the input parameters provided by the first transaction meet the execution conditions when judging that the above-mentioned event type and the data format of the parameters conform to the specified format of the called method. It can be seen that if the processing progress of the workflow at the current moment is ahead of the task node A, the execution condition is met as a trigger condition for the blockchain node to generate a task assignment event corresponding to the task node A. For example, when the first transaction calls the aforementioned transit method of the contract, the provided parameter ev can be
Figure PCTCN2022093802-appb-000001
Figure PCTCN2022093802-appb-000001
在另一实施例中,上述第一任务结点的执行条件也可以为:第一交易提供的入参为工作流中处于第一任务结点之前的第二任务结点所对应的第二待执行任务的执行结果。例如,在第一待执行任务为合约任务B、第二待执行任务为合约任务B所依赖的合约任务A的情况下,第一任务结点即为合约任务B对应的任务结点B,此时,合约任务A的执行结果可以作为合约任务B的入参,从而在第一交易提供的入参为合约任务A的执行结果(即表明当前时刻合约任务A已经执行完毕)的情况下,相应的区块链节点实例可以确定第一交易提供的入参满足执行条件。可见,若当前时刻工作流的处理进度处于任务结点B之前,则该执行条件被满足可以作为节点设备生成对应于任务结点B的任务分配事件的触发条件。In another embodiment, the execution condition of the above-mentioned first task node may also be: the input parameter provided by the first transaction is the second pending task corresponding to the second task node before the first task node in the workflow. The execution result of the execution task. For example, when the first task to be executed is contract task B, and the second task to be executed is contract task A on which contract task B depends, the first task node is the task node B corresponding to contract task B. When , the execution result of contract task A can be used as the input parameter of contract task B, so when the input parameter provided by the first transaction is the execution result of contract task A (that is, it indicates that contract task A has been executed at the current moment), the corresponding The block chain node instance can determine that the input parameters provided by the first transaction meet the execution conditions. It can be seen that if the processing progress of the workflow at the current moment is ahead of the task node B, then the execution condition being satisfied can be used as a trigger condition for the node device to generate a task assignment event corresponding to the task node B.
当然,第一任务结点的执行条件也可以同时包含上述两种,即该执行条件可以为“第一交易提供的入参为工作流中处于第一任务结点之前的第二任务结点所对应的第二待执行任务的执行结果,且该执行结果的数据格式符合要求”,从而对工作流中任一任务的入参实现更严苛的管理。Of course, the execution condition of the first task node can also include the above two at the same time, that is, the execution condition can be "the input parameter provided by the first transaction is provided by the second task node before the first task node in the workflow." The execution result of the corresponding second to-be-executed task, and the data format of the execution result meets the requirements", so as to achieve stricter management on the input parameters of any task in the workflow.
在一实施例中,本说明书所述的节点设备中部署有区块链平台代码,节点设备运行该平台代码的过程中即在本地形成区块链节点实例,从而在该节点设备中形成区块链节点;另外,节点设备中还可以部署有区块链业务代码,节点设备运行该业务代码的过程中即在本地形成业务实例。其中,区块链节点实例可以用于生成上述任务分配事件,业务实例可以用于在监听到任务分配事件且确定自身所在节点设备所属的区块链成员为第一待执行任务的执行方的情况下,参与执行第一待执行任务。可见,执行智能合约的区块链节点可以生成上述任务分配事件,而区块链网络中任一区块链节点所在节点设备中的业务实例在监听到该事件后,可以根据该事件确定自身所在节点设备所属的区块链成员是否为第一待执行任务的执行方,进而在确定为是的情况下参与执行第一待执行任务;当然,在确定为否的情况下,可以直接丢弃该事件。In one embodiment, the block chain platform code is deployed in the node device described in this specification, and the block chain node instance is formed locally when the node device runs the platform code, thereby forming a block in the node device In addition, the node device can also be deployed with a blockchain business code, and the node device will form a business instance locally during the process of running the business code. Among them, the blockchain node instance can be used to generate the above-mentioned task allocation event, and the business instance can be used to monitor the task allocation event and determine that the blockchain member to which the node device belongs is the executor of the first task to be executed Next, participate in the execution of the first task to be executed. It can be seen that the blockchain node that executes the smart contract can generate the above task assignment event, and the business instance in the node device where any blockchain node in the blockchain network is located can determine its location based on the event after listening to the event. Whether the blockchain member to which the node device belongs is the executor of the first task to be executed, and then participate in the execution of the first task to be executed if it is determined to be yes; of course, in the case of no, the event can be directly discarded .
在一实施例中,区块链节点实例可以将分配对象的区块链成员的身份信息包含在任务分配事件中,从而区块链网络的任一区块链节点所在节点设备中部署的业务实例可以在监听到任务分配事件且确定自身所在节点设备所属的区块链成员为第一待执行任务的执行方的情况下,确定该任务分配事件所含的第一合约任务被分配至第一节点设备所属的第一区块链成员,即确定由自身所处节点设备中部署的业务实例执行该第一合约任务。其中,上述身份信息可以为区块链成员的成员标识,也可以为节点设备的设备标识(一个节点设备中仅部署该区块链网络中的一个区块链节点的情况下),还可以为该区块链成员所对应区块链节点的节点公钥或者节点公钥的摘要等,本说明书并不对此进行限制。或者,也可以预先为区块链成员指定相应的任务分配条件,从而任一区块链节点可以在第一合约任务的任务内容匹配于自身对应的区块链节点成员的任务分配条件的情况下,确定该任务分配事件所含的第一合约任务被分配至自身对应的区块链节点成员,即确定由该区块链节点成员对应的业务实例执行该第一合约任务。实际上,本说明书的下述实施例中,任一区块链节点均可以通过上述方式确定自身对应的区块链节点成员是否为所述第一待执行任务的执行方,下述实施例不再赘述。In an embodiment, the blockchain node instance can include the identity information of the blockchain member of the assigned object in the task assignment event, so that the business instance deployed in the node device where any blockchain node of the blockchain network is located It can be determined that the first contract task included in the task assignment event is assigned to the first node when the task assignment event is monitored and the blockchain member to which the node device belongs is determined to be the executor of the first task to be executed The first block chain member to which the device belongs, that is, it is determined that the service instance deployed in the node device where it is located executes the first contract task. Among them, the above-mentioned identity information can be the member identification of the block chain member, or the device identification of the node device (in the case that only one block chain node in the block chain network is deployed in one node device), it can also be The node public key of the blockchain node corresponding to the blockchain member or the summary of the node public key, etc., are not limited in this manual. Alternatively, it is also possible to specify corresponding task assignment conditions for blockchain members in advance, so that any blockchain node can It is determined that the first contract task included in the task assignment event is assigned to its corresponding blockchain node member, that is, it is determined that the first contract task is executed by the business instance corresponding to the blockchain node member. In fact, in the following embodiments of this specification, any blockchain node can determine whether its corresponding blockchain node member is the executor of the first task to be executed in the above-mentioned manner. The following embodiments do not Let me repeat.
在一实施例中,上述第一待执行任务可以存在多个执行方,此时,各个执行方对应的业务实例可以分别执行第一待执行任务。当然,上述第一待执行任务也可以包含多个子任务,此时各执行方对应的业务实例也可以分别执行上述多个子任务。In an embodiment, there may be multiple executors for the first to-be-executed task, and at this time, the service instances corresponding to each executor may respectively execute the first to-be-executed task. Certainly, the above-mentioned first task to be executed may also include multiple subtasks, and at this time, the service instances corresponding to each executing party may also respectively execute the above-mentioned multiple subtasks.
在一实施例中,上述第一待执行任务可以为隐私计算、文件系统访问、数据库访问等多种任务形式,从而业务实例还可以通过多种方式执行第一待执行任务。例如,业务实例可以调用部署于节点设备本地的计算资源执行第一待执行任务,如节点设备1中的业务实例可以调用节点设备1本地部署的任务单元容器11所管理的任务单元执行合约任务A(此时,合约任务A为第一待执行任务)。又例如,业务实例也可以调用部署于节点设备之外的计算资源执行第一待执行任务,如节点设备2中的业务实例可以调用节点设备2本地部署的任务单元容器21所管理的任务单元和节点设备2之外的其他设备中部署的链外计算资源合作执行合约任务C(此时,合约任务C为第一待执行任务)。当然,节点设备1中的业务实例也可以同时调用部署于节点设备本地的多个计算资源执行合约任务A,或者节点设备2中的业务实例也可以仅调用链外计算资源执行合约任务C,本说明书并不对此进行限制。在方案实践中,可以根据任务类型、计算资源消耗量、耗时要求等实际任务需求灵活选择合适的计算资源执行第一待执行任务,从而实现更灵活的方案实践、扩大本说明书所述方法的适用场景。In an embodiment, the above-mentioned first task to be performed may be in the form of various tasks such as private computing, file system access, and database access, so that the business instance may also perform the first task to be performed in various ways. For example, the service instance can call the computing resources deployed locally on the node device to execute the first task to be executed, for example, the service instance in the node device 1 can call the task unit managed by the task unit container 11 deployed locally on the node device 1 to execute the contract task A (At this point, contract task A is the first task to be executed). For another example, the service instance may also call computing resources deployed outside the node device to execute the first task to be executed, for example, the service instance in the node device 2 may call the task unit managed by the task unit container 21 locally deployed on the node device 2 and The off-chain computing resources deployed in other devices than the node device 2 cooperate to execute the contract task C (at this time, the contract task C is the first task to be executed). Of course, the business instance in node device 1 can also call multiple computing resources deployed locally on the node device to execute contract task A, or the business instance in node device 2 can also only call off-chain computing resources to execute contract task C. The description does not limit this. In program practice, appropriate computing resources can be flexibly selected to execute the first task to be executed according to actual task requirements such as task type, computing resource consumption, and time-consuming requirements, so as to realize more flexible program practice and expand the scope of the method described in this specification. Applicable scene.
在一实施例中,任一节点设备在部署上述区块链节点实例和业务实例的过程中,可以分别拉起多个进程,并在不同进程中分别运行上述区块链平台代码和区块链任务代码,从而将区块链节点实例和业务实例分别部署在不同的进程中,相应的,区块链节点实例和业务实例之间可以通过跨进程交互实现数据传输。通过该方式,保证区块链节点实例和业务实例在运行过程中产生尽量少的干扰,并实现不同实例之间的故障隔离。或者,为了减少上述跨进程交互过程中可能产生的延迟,以保证智能合约执行过程中的任务执行效率,节点设备也可以将上述区块链节点实例和业务实例部署在同一进程中,本说明书对此并不进行限制。In an embodiment, during the process of deploying the above-mentioned blockchain node instance and business instance, any node device can pull up multiple processes respectively, and run the above-mentioned blockchain platform code and blockchain respectively in different processes. Task code, so that the blockchain node instance and the business instance are deployed in different processes. Correspondingly, data transmission can be realized through cross-process interaction between the blockchain node instance and the business instance. In this way, it is ensured that blockchain node instances and business instances generate as little interference as possible during operation, and fault isolation between different instances is realized. Or, in order to reduce the delay that may occur during the above-mentioned cross-process interaction and ensure the task execution efficiency during the execution of the smart contract, the node device can also deploy the above-mentioned blockchain node instance and business instance in the same process. This is not limiting.
在一实施例中,区块链网络中的任一区块链节点在监听到针对第一待执行任务的任务分配事件后,可以判断自身对应的区块链节点成员是否为第一待执行任务的执行方,进而在确定自身对应的区块链节点成员为第一待执行任务的执行方的情况下,可以在自身所在节点设备中创建子网节点实例,并与第一待执行任务的其他执行方所创建的子网节点实例组建区块链子网。进而,区块链节点可以在组建的区块链子网上提交子网交易,以由自身对应的区块链节点成员执行第一待执行任务——区块链子网中的各个子网节点均会执行该交易,从而由区块链子网完成该交易的执行。以图4所示场景为例,假设区块链主网subnet0中部署有智能合约,则nodeA、nodeB、nodeC、nodeD和nodeE在分别监听到任一节点生成的任务分配事件后,可以分别确定自身是否为该事件对应的待执行任务的执行方:若nodeA、nodeB、nodeC和nodeD分别确定自身为该待执行任务的执行方,则可以分别创建子网节点实例nodeA1、nodeB1、nodeC1和nodeD1,并组建包含上述各个子网节点实例的区块链子网subnet1,进而在该subnet1中执行上述任务分配事件对应的待执行任务。In one embodiment, any blockchain node in the blockchain network can determine whether its corresponding blockchain node member is the first task to be executed after listening to the task assignment event for the first task to be executed executor, and then in the case of determining that its corresponding block chain node member is the executor of the first task to be executed, it can create a subnetwork node instance in the node device where it is located, and communicate with other members of the first task to be executed The subnetwork node instance created by the executor forms a blockchain subnetwork. Furthermore, blockchain nodes can submit subnetwork transactions on the established blockchain subnetwork, so that their corresponding blockchain node members can execute the first task to be executed—each subnetwork node in the blockchain subnetwork will execute The transaction is thus executed by the blockchain subnetwork. Taking the scenario shown in Figure 4 as an example, assuming that smart contracts are deployed in subnet0 of the blockchain main network, nodeA, nodeB, nodeC, nodeD, and nodeE can respectively determine their own Whether it is the executor of the task to be executed corresponding to the event: If nodeA, nodeB, nodeC, and nodeD respectively determine themselves to be the executor of the task to be executed, they can create subnetwork node instances nodeA1, nodeB1, nodeC1, and nodeD1 respectively, and Set up a block chain subnet subnet1 containing the above subnet node instances, and then execute the tasks to be executed corresponding to the above task assignment events in the subnet1.
可见,区块链网络中的各个区块链节点在监听到同一任务分配事件后,该任务分配事件对应的待执行任务的各个执行方能够相应的组建区块链子网,并通过各个区块链节点在该子网中的相互协作完成针对待执行任务的执行。显然,此时的区块链网络即相当于区块链主网,而其中各个区块链节点构成的网络即为区块链子网,从而通过在区块链主网的基础上组建区块链子网,保证了该任务分配事件所对应区块链节点执行过程中的相关数据不会被区块链主网中的其他无关节点获知,有效保证了数据的小范围私密性。而且,上述相关数据和任务的执行结果可以以区块链子网所对应数据的身份被存证,而不会与区块链主网的数据相混淆,进一步保证了数据的安全性和私密性。It can be seen that after each blockchain node in the blockchain network monitors the same task assignment event, each executor of the task to be executed corresponding to the task assignment event can build a blockchain subnet accordingly, and through each blockchain The mutual cooperation of nodes in this subnetwork completes the execution of tasks to be executed. Obviously, the blockchain network at this time is equivalent to the blockchain main network, and the network composed of each blockchain node is the blockchain subnet. The network ensures that the relevant data in the execution process of the blockchain node corresponding to the task assignment event will not be known by other irrelevant nodes in the blockchain main network, effectively ensuring the small-scale privacy of the data. Moreover, the execution results of the above-mentioned relevant data and tasks can be stored in the identity of the data corresponding to the blockchain subnet, without being confused with the data of the blockchain main network, which further ensures the security and privacy of the data.
下面以一具体实施例进行说明。例如针对某个项目S,其工作流包括:A specific embodiment will be described below. For example, for a project S, its workflow includes:
第一步:从商店SSS的数据库中拉取数据并进行处理,然后将其中满足特定条件的作为本步骤输出结果并保存到区块链上。Step 1: Pull data from the database of the store SSS and process it, and then output the result of this step as the output result of this step and save it on the blockchain.
第二步:构建一个区块链子网,由该区块链子网的参与方对上一步的结果进行共识。Step 2: Build a blockchain subnet, and the participants of the blockchain subnet will agree on the results of the previous step.
显然,上述两步可以对应于两个存在依赖关系的待执行任务(即下述的MYTASK1和MYTASK2)。相应的,使用OpenWDL语言编写的任务代码可以如下:Apparently, the above two steps may correspond to two tasks to be executed with dependencies (ie, MYTASK1 and MYTASK2 described below). Correspondingly, the task code written in OpenWDL language can be as follows:
Figure PCTCN2022093802-appb-000002
Figure PCTCN2022093802-appb-000002
其中,上述子网交易可以包括用于调用智能合约的区块链交易。例如对应于上述任务代码,第一待执行任务为第一步对应的任务MYTASK1,在subnet中发起的子网交易可以为调用智能合约中对应于任务MYTASK1部分的合约代码的区块链交易,从而subnet中的各节点可以分别执行这部分合约代码,完成任务MYTASK1的执行。Wherein, the above-mentioned subnet transactions may include blockchain transactions for invoking smart contracts. For example, corresponding to the above task code, the first task to be executed is the task MYTASK1 corresponding to the first step, and the subnet transaction initiated in the subnet can be a blockchain transaction that calls the contract code corresponding to the part of the task MYTASK1 in the smart contract, so that Each node in the subnet can execute this part of the contract code to complete the execution of the task MYTASK1.
具体的,上述子网交易的执行方式可以有多种。例如,第一待执行任务的执行方在区块链子网中对应的子网节点可以均为共识节点,此时子网交易通过区块链子网的共识后,被各子网节点分别执行。从而通过共识保证被执行的子网交易的可靠性。或者,在上述第一待执行任务包括多个子任务的情况下,第一待执行任务的执行方在区块链子网中对应的子网节点也可以均为非共识节点,此时子网交易不经过区块链子网的共识, 即可由各子网节点分别执行不同的子任务。可见,此时的子网交易无需经过共识,因此各个子网节点可以分别同步执行各自的子网交易,有助于提升区块链交易的执行效率。Specifically, there are many ways to execute the above-mentioned subnetwork transactions. For example, the subnetwork nodes corresponding to the executor of the first task to be executed in the blockchain subnetwork may all be consensus nodes. At this time, the subnetwork transactions are executed by each subnetwork node after passing the consensus of the blockchain subnetwork. In this way, the reliability of the executed subnet transactions is guaranteed through consensus. Alternatively, when the above-mentioned first task to be executed includes multiple subtasks, the subnetwork nodes corresponding to the executor of the first task to be executed in the blockchain subnetwork may also be non-consensus nodes. After the consensus of the blockchain subnetwork, different subtasks can be performed by each subnetwork node. It can be seen that the sub-network transactions at this time do not need to go through consensus, so each sub-network node can execute their own sub-network transactions synchronously, which helps to improve the execution efficiency of blockchain transactions.
当然,在上述实施例中,响应于任务分配事件建立的区块链子网,可以在任务分配事件对应的区块链交易被响应完成后(即第一待执行任务执行完成后)被解散,使得建立的区块链子网随着区块链交易的执行而构建、随着交易的执行结束而解散,从而实现区块链子网的临时建立。显然,该区块链子网的生命周期与相应区块链交易的生命周期相同,避免了区块链节点同时维护过多区块链网络的网络信息可能导致的效率降低。Certainly, in the above-mentioned embodiment, the block chain subnet established in response to the task assignment event can be disbanded after the block chain transaction corresponding to the task assignment event is responded to (that is, after the execution of the first task to be executed is completed), so that The established blockchain subnetwork is constructed along with the execution of the blockchain transaction, and disbanded with the execution of the transaction, thus realizing the temporary establishment of the blockchain subnetwork. Obviously, the life cycle of the blockchain subnet is the same as the life cycle of the corresponding blockchain transaction, which avoids the possible reduction in efficiency caused by the simultaneous maintenance of too many blockchain network network information by blockchain nodes.
在前述多个实施例中,第一待执行任务可以包含多个子任务,各子任务的执行方可以按照预设顺序执行各子任务,该预设顺序可以为工作流中定义的执行顺序,从而保证各个子任务的执行顺序与工作流对应,进一步保证第一待执行任务得到正确的执行结果。In the foregoing multiple embodiments, the first task to be executed may include multiple subtasks, and the executor of each subtask may execute each subtask in a preset order, and the preset order may be the execution order defined in the workflow, so that Ensure that the execution sequence of each subtask corresponds to the workflow, and further ensure that the first task to be executed gets a correct execution result.
但是,区块链网络中部署的智能合约可以被多次执行,因此若每次执行智能合约都重新组建区块链子网,难免会降低区块链子网的利用率并导致区块链交易的响应时间延长。为解决这一问题,可以在智能合约部署后(智能合约执行前)预先组建区块链子网,即任一区块链节点在部署完成智能合约后,即根据该合约中记载的任务相关信息(各个待执行任务的执行方)组建分别对应于各个待执行任务的区块链子网。使得区块链节点对应的节点设备上部署有区块链网络的网络节点实例和区块链网络所管理的区块链子网的子网节点实例,从而,子网节点实例在监听到任务分配事件且确定自身对应的子网节点成员为第一待执行任务的执行方的情况下,可以在区块链子网上提交子网交易,以由自身对应的子网节点成员参与执行第一待执行任务。However, the smart contracts deployed in the blockchain network can be executed multiple times, so if the blockchain subnet is rebuilt every time the smart contract is executed, it will inevitably reduce the utilization rate of the blockchain subnet and cause the response of blockchain transactions Prolonged. In order to solve this problem, the blockchain subnetwork can be pre-established after the smart contract is deployed (before the smart contract is executed), that is, after any blockchain node deploys the smart contract, it will be based on the task-related information recorded in the contract ( The executor of each task to be executed) establishes a blockchain subnet corresponding to each task to be executed. The network node instance of the blockchain network and the subnetwork node instance of the blockchain subnet managed by the blockchain network are deployed on the node device corresponding to the blockchain node, so that the subnetwork node instance listens to the task assignment event And when it is determined that the corresponding subnetwork node member is the executor of the first task to be executed, the subnetwork transaction can be submitted on the blockchain subnet, so that the subnetwork node member corresponding to itself can participate in the execution of the first task to be executed.
在一实施例中,在当前时刻工作流的处理进度处于第一任务结点之前且第一交易提供的入参使第一任务结点的执行条件被满足的情况下,区块链节点实例还可将工作流的处理进度更新至第一任务结点之后,从而推动智能合约所对应工作流状态的状态迁移。In one embodiment, when the processing progress of the workflow at the current moment is ahead of the first task node and the input provided by the first transaction satisfies the execution conditions of the first task node, the blockchain node instance also The processing progress of the workflow can be updated after the first task node, thereby promoting the state transition of the workflow state corresponding to the smart contract.
在一实施例中,区块链节点可以在执行第一待执行任务后,通过智能合约中的任务回调方法将该任务的执行结果返回至第一任务结点之后。从而当第一交易调用智能合约中的任务回调方法时,即表明第一交易提供的入参为第二待执行任务的执行结果;其中,该任务回调方法被调用后,可以自动触发用于推进工作流的方法。In an embodiment, after executing the first task to be executed, the block chain node can return the execution result of the task to the first task node through the task callback method in the smart contract. Therefore, when the first transaction calls the task callback method in the smart contract, it indicates that the input parameter provided by the first transaction is the execution result of the second task to be executed; wherein, after the task callback method is called, it can be automatically triggered to advance Workflow method.
可见,上述方案允许用户使用工作流描述语言对具体业务的工作流进行描述,从而生成通过该语言编写的任务代码,并通过自动化的编译器对任务代码进行编译,以直接生成可以用于部署的合约代码。可见,通过统一的标准化工作流描述语言对工作流进行描述,提升了所生成合约代码的标准化程度;而且相对于直接编写合约代码,允许用户使用该语言编写任务代码,并使用编译器根据任务代码自动生成合约代码,有效保证了标准化智能合约的生成效率和执行效率。It can be seen that the above scheme allows users to use the workflow description language to describe the workflow of a specific business, thereby generating task codes written in this language, and compiling the task codes through an automated compiler to directly generate deployment-ready contract code. It can be seen that the workflow is described through a unified standardized workflow description language, which improves the standardization of the generated contract code; and compared with directly writing contract code, users are allowed to use this language to write task code, and use the compiler to compile task code according to the task code. The contract code is automatically generated, effectively ensuring the generation and execution efficiency of standardized smart contracts.
图8是一示例性实施例提供的一种设备的结构示意图。请参考图8,在硬件层面,该设备包括处理器802、内部总线804、网络接口806、内存808以及非易失性存储器810,当然还可能包括其他业务所需要的硬件。本说明书一个或多个实施例可以基于软件方式来实现,比如由处理器802从非易失性存储器810中读取对应的计算机程序到内存808中然后运行。当然,除了软件实现方式之外,本说明书一个或多个实施例并不排除其他实现方式,比如逻辑器件抑或软硬件结合的方式等等,也就是说以下处理流程的执行主体并不限定于各个逻辑单元,也可以是硬件或逻辑器件。Fig. 8 is a schematic structural diagram of a device provided by an exemplary embodiment. Please refer to FIG. 8 , at the hardware level, the device includes a processor 802 , an internal bus 804 , a network interface 806 , a memory 808 and a non-volatile memory 810 , and of course may also include hardware required by other services. One or more embodiments of this specification may be implemented based on software, for example, the processor 802 reads a corresponding computer program from the non-volatile memory 810 into the memory 808 and executes it. Of course, in addition to software implementations, one or more embodiments of this specification do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each A logic unit, which can also be a hardware or logic device.
图9是一示例性实施例提供的一种智能合约部署装置的框图。请参考图9,该装置可以应用于如图8所示的设备中,以实现本说明书的技术方案。其中,该智能合约部署装置可以包括:代码获取单元901,使获取使用工作流描述语言对工作流进行描述而生成的任务代码;代码编译单元902,使通过编译器对所述任务代码进行编译,生成用于表征所述工作流的合约代码;交易部署单元903,使向区块链网络发送用于部署所述合约代码的区块链交易,以在所述区块链网络中部署相应的智能合约,所述智能合约用于 在被调用时根据所述工作流中各任务结点所定义的业务逻辑向参与所述区块链网络的节点成员分配待执行任务。Fig. 9 is a block diagram of a smart contract deployment device provided by an exemplary embodiment. Please refer to FIG. 9 , the device can be applied to the device shown in FIG. 8 to realize the technical solution of this specification. Wherein, the smart contract deployment device may include: a code acquisition unit 901, which acquires the task code generated by describing the workflow using a workflow description language; a code compilation unit 902, which compiles the task code through a compiler, Generate the contract code used to characterize the workflow; the transaction deployment unit 903 sends the blockchain transaction used to deploy the contract code to the blockchain network to deploy the corresponding intelligent A contract, the smart contract is used to assign tasks to be executed to the node members participating in the blockchain network according to the business logic defined by each task node in the workflow when called.
可选的,所述代码获取单元901还用于:接收客户端发送的所述任务代码;或者,根据客户端对预定义的任务模板提供的配置信息,生成所述任务代码。Optionally, the code obtaining unit 901 is further configured to: receive the task code sent by the client; or generate the task code according to configuration information provided by the client for a predefined task template.
可选的,所述代码编译单元902还用于下述之一:将所述任务代码编译为高级语言编写的合约代码;将所述任务代码编译为字节码,并将所述字节码作为所述合约代码;先将所述任务代码编译为高级语言编写的代码,再将所述高级语言编写的代码进一步编译为字节码,并将所述字节码作为所述合约代码。Optionally, the code compiling unit 902 is also used for one of the following: compiling the task code into a contract code written in a high-level language; compiling the task code into bytecode, and compiling the bytecode As the contract code: first compile the task code into a code written in a high-level language, then further compile the code written in the high-level language into a bytecode, and use the bytecode as the contract code.
可选的,所述交易部署单元903还用于:在所述合约代码由高级语言编写的情况下,将所述合约代码编译为字节码,并在所述区块链网络中部署该字节码;或者,在所述合约代码由高级语言编写的情况下,在所述区块链网络中部署所述高级语言编写的所述合约代码,并在部署完成后立即开始将所述合约代码编译为字节码。Optionally, the transaction deployment unit 903 is further configured to: compile the contract code into bytecode when the contract code is written in a high-level language, and deploy the bytecode in the blockchain network section code; or, in the case that the contract code is written in a high-level language, deploy the contract code written in the high-level language in the block chain network, and immediately start converting the contract code to Compiled to bytecode.
另外,图10是一示例性实施例提供的另一种智能合约部署装置的框图。请参考图10,该装置可以应用于如图8所示的设备中,以实现本说明书的技术方案。其中,该智能合约部署装置应用于区块链网络中的区块链节点,可以包括:合约部署单元1001,使响应于接收到的部署合约代码的区块链交易,在所述区块链网络中部署相应的智能合约;所述合约代码由编译器对任务代码进行编译而生成,所述任务代码由工作流描述语言对工作流进行描述而生成;合约调用单元1002,使响应于接收到的调用所述智能合约的区块链交易,根据所述工作流中各任务结点所定义的业务逻辑向参与所述区块链网络的节点成员分配待执行任务。In addition, FIG. 10 is a block diagram of another smart contract deployment device provided by an exemplary embodiment. Please refer to FIG. 10 , the device can be applied to the device shown in FIG. 8 to realize the technical solution of this specification. Wherein, the smart contract deployment device is applied to the blockchain nodes in the blockchain network, and may include: the contract deployment unit 1001, which responds to the received blockchain transaction of deploying the contract code, in the blockchain network Deploy the corresponding smart contract; the contract code is generated by compiling the task code by the compiler, and the task code is generated by describing the workflow in the workflow description language; the contract calling unit 1002 makes the response to the received Invoke the block chain transaction of the smart contract, assign tasks to be executed to the node members participating in the block chain network according to the business logic defined by each task node in the workflow.
可选的,还包括:事件生成单元1003,使在所述工作流的处理进度处于第一任务结点之前且第一交易提供的入参使第一任务结点的执行条件被满足的情况下,生成包含第一任务结点所对应第一待执行任务的任务分配事件。Optionally, it also includes: an event generating unit 1003, which makes the processing progress of the workflow be ahead of the first task node and the input parameters provided by the first transaction satisfy the execution condition of the first task node , generating a task assignment event including the first task to be executed corresponding to the first task node.
可选的,所述执行条件包括下述至少之一:第一交易提供的入参的数据格式符合要求;第一交易提供的入参为所述工作流中处于第一任务结点之前的第二任务结点所对应的第二待执行任务的执行结果。Optionally, the execution condition includes at least one of the following: the data format of the input parameter provided by the first transaction meets the requirements; the input parameter provided by the first transaction is the first task node before the first task node in the workflow. The execution result of the second to-be-executed task corresponding to the second task node.
可选的,所述区块链节点对应的节点设备上部署有区块链节点实例和业务实例,所述区块链节点实例用于生成所述任务分配事件,所述业务实例用于在监听到所述任务分配事件且确定自身所在节点设备所属的区块链成员为所述第一待执行任务的执行方的情况下,参与执行所述第一待执行任务。Optionally, a block chain node instance and a service instance are deployed on the node device corresponding to the block chain node, the block chain node instance is used to generate the task assignment event, and the service instance is used to monitor Participate in the execution of the first to-be-executed task when the task assignment event occurs and the block chain member to which the node device belongs is determined to be the executor of the first to-be-executed task.
可选的,所述第一待执行任务存在多个执行方,各执行方对应的业务实例分别执行所述第一待执行任务,或者各执行方对应的业务实例分别执行所述第一待执行任务包含的多个子任务。Optionally, there are multiple executors for the first to-be-executed task, and the business instances corresponding to each executor respectively execute the first to-be-executed task, or the business instances corresponding to each executor respectively execute the first to-be-executed task A task contains multiple subtasks.
可选的,任一执行方对应的业务实例执行任一任务,包括:所述业务实例调用部署于自身所在节点设备本地的计算资源执行所述任一任务;和/或,所述业务实例调用部署于自身所在节点设备之外的计算资源执行所述任一任务。Optionally, the service instance corresponding to any executor executes any task, including: the service instance invokes a local computing resource deployed on the node device where it is located to execute any task; and/or, the service instance invokes The computing resource deployed outside the node device where it is located executes any of the above tasks.
可选的,任一节点设备中部署的所述区块链节点实例和所述业务实例处于不同进程。Optionally, the blockchain node instance and the service instance deployed in any node device are in different processes.
可选的,所述区块链节点对应的节点设备上部署有所述区块链网络的网络节点实例和所述区块链网络所管理的区块链子网的子网节点实例,所述子网节点实例在监听到所述任务分配事件且确定自身对应的子网节点成员为所述第一待执行任务的执行方的情况下,在所述区块链子网上提交子网交易,以由自身对应的子网节点成员参与执行所述第一待执行任务。Optionally, the node device corresponding to the blockchain node is deployed with a network node instance of the blockchain network and a subnet node instance of the blockchain subnet managed by the blockchain network, the subnet When the network node instance listens to the task allocation event and determines that its corresponding subnetwork node member is the executor of the first task to be executed, it submits a subnetwork transaction on the blockchain subnetwork, so that The corresponding subnetwork node members participate in executing the first task to be executed.
可选的,还包括:子网创建单元1004,使在监听到所述任务分配事件且确定自身对应的区块链节点成员为所述第一待执行任务的执行方的情况下,在自身所在节点设备中创建子网节点实例,并与所述第一待执行任务的其他执行方所创建的子网节点实例组 建区块链子网;交易提交单元1005,使在组建的所述区块链子网上提交子网交易,以由自身对应的区块链节点成员执行所述第一待执行任务。Optionally, it also includes: the subnet creation unit 1004, so that when the task allocation event is monitored and the block chain node member corresponding to itself is determined to be the executor of the first task to be executed, in its own Create a subnet node instance in the node device, and form a block chain subnet with the subnet node instances created by other executors of the first to-be-executed task; the transaction submission unit 1005 makes the established block chain subnet Submit a subnetwork transaction, so that the first task to be executed is executed by its corresponding block chain node member.
可选的,所述子网交易包括用于调用所述智能合约的交易。Optionally, the subnet transaction includes a transaction for invoking the smart contract.
可选的,所述第一待执行任务的执行方在所述区块链子网中对应的子网节点均为共识节点,所述子网交易通过所述区块链子网的共识后,被各子网节点分别执行。Optionally, the corresponding subnet nodes of the executor of the first to-be-executed task in the blockchain subnet are all consensus nodes, and after the subnet transaction passes the consensus of the blockchain subnet, it is accepted by each Subnetwork nodes are executed separately.
可选的,所述第一待执行任务包括多个子任务,所述第一待执行任务的执行方在所述区块链子网中对应的子网节点均为非共识节点,所述子网交易不经过所述区块链子网的共识,并由各子网节点分别执行不同的子任务。Optionally, the first to-be-executed task includes a plurality of sub-tasks, and the sub-network nodes corresponding to the executor of the first to-be-executed task in the blockchain sub-network are all non-consensus nodes, and the sub-network transaction Without going through the consensus of the blockchain subnetwork, each subnetwork node performs different subtasks respectively.
可选的,任一区块链节点确定自身对应的区块链节点成员为所述第一待执行任务的执行方,包括:所述任务分配事件中包含所述任一区块链节点对应的区块链节点成员的身份信息;或者,第一待执行任务的任务内容匹配于所述任一区块链节点对应的区块链节点成员对应的任务分配条件。Optionally, any blockchain node determines that its corresponding blockchain node member is the executor of the first to-be-executed task, including: the task assignment event includes the The identity information of the blockchain node members; or, the task content of the first task to be executed matches the task allocation conditions corresponding to the blockchain node members corresponding to any of the blockchain nodes.
可选的,各子任务的执行方分别按照所述工作流中定义的执行顺序执行各子任务。Optionally, the executor of each subtask executes each subtask according to the execution sequence defined in the workflow.
可选的,还包括:进度更新单元1006,使在所述工作流的处理进度处于第一任务结点之前且第一交易提供的入参使第一任务结点的执行条件被满足的情况下,所述区块链节点实例将所述工作流的处理进度更新至第一任务结点之后。Optionally, it also includes: a progress updating unit 1006, so that when the processing progress of the workflow is before the first task node and the input parameters provided by the first transaction satisfy the execution condition of the first task node , the block chain node instance updates the processing progress of the workflow after the first task node.
可选的,所述待执行任务的任一执行方还用于:调用所述智能合约中的任务回调方法,将所述待执行任务的执行结果返回至所述智能合约。Optionally, any executor of the to-be-executed task is further configured to: call a task callback method in the smart contract, and return the execution result of the to-be-executed task to the smart contract.
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机。具体的,计算机例如可以为个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。The systems, devices, modules, or units described in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementing device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or Combinations of any of these devices.
为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本说明书时可以把各单元的功能在同一个或多个软件和/或硬件中实现。For the convenience of description, when describing the above devices, functions are divided into various units and described separately. Of course, when implementing this specification, the functions of each unit can be implemented in one or more pieces of software and/or hardware.
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present invention may be provided as methods, systems, or computer program products. Accordingly, the present invention can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should be understood that each procedure and/or block in the flowchart and/or block diagram, and a combination of procedures and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor, or processor of other programmable data processing equipment to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing equipment produce a An apparatus for realizing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
本说明书可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组建、数据结构等等。也可以在分布式计算环境中实践本说明书,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。The specification may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The present description may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including storage devices.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions The device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。在一个典型的配置中,计算机包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。These computer program instructions can also be loaded onto a computer or other programmable data processing device, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby The instructions provide steps for implementing the functions specified in the flow chart or blocks of the flowchart and/or the block or blocks of the block diagrams. In a typical configuration, a computer includes one or more processors (CPUs), input/output interfaces, network interfaces and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。Memory may include non-permanent storage in computer-readable media, in the form of random access memory (RAM) and/or nonvolatile memory such as read-only memory (ROM) or flash RAM. Memory is an example of computer readable media.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带、磁盘存储、量子存储器、基于石墨烯的存储介质或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can be implemented by any method or technology for storage of information. Information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, Magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by computing devices. As defined herein, computer-readable media excludes transitory computer-readable media, such as modulated data signals and carrier waves.
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。It should also be noted that the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article, or apparatus comprising a set of elements includes not only those elements, but also includes Other elements not expressly listed, or elements inherent in the process, method, commodity, or apparatus are also included. Without further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article or apparatus comprising said element.
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。The foregoing describes specific embodiments of this specification. Other implementations are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. Multitasking and parallel processing are also possible or may be advantageous in certain embodiments.
在本说明书一个或多个实施例使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本说明书一个或多个实施例。在本说明书一个或多个实施例和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。还应当理解,本文中使用的术语“和/或”是指并包含一个或多个相关联的列出项目的任何或所有可能组合。Terms used in one or more embodiments of the present specification are for the purpose of describing specific embodiments only, and are not intended to limit the one or more embodiments of the present specification. As used in one or more embodiments of this specification and the appended claims, the singular forms "a", "the", and "the" are also intended to include the plural forms unless the context clearly dictates otherwise. It should also be understood that the term "and/or" as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.
应当理解,尽管在本说明书一个或多个实施例可能采用术语第一、第二、第三等来描述各种信息,但这些信息不应限于这些术语。这些术语仅用来将同一类型的信息彼此区分开。例如,在不脱离本说明书一个或多个实施例范围的情况下,第一信息也可以被称为第二信息,类似地,第二信息也可以被称为第一信息。取决于语境,如在此所使用的词语“如果”可以被解释成为“在……时”或“当……时”或“响应于确定”。It should be understood that although the terms first, second, third, etc. may be used in one or more embodiments of the present specification to describe various information, the information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of one or more embodiments of this specification, first information may also be called second information, and similarly, second information may also be called first information. Depending on the context, the word "if" as used herein may be interpreted as "at" or "when" or "in response to a determination."
以上所述仅为本说明书一个或多个实施例的较佳实施例而已,并不用以限制本说明书一个或多个实施例,凡在本说明书一个或多个实施例的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本说明书一个或多个实施例保护的范围之内。The above descriptions are only preferred embodiments of one or more embodiments of this specification, and are not intended to limit one or more embodiments of this specification. Within the spirit and principles of one or more embodiments of this specification, Any modification, equivalent replacement, improvement, etc. should be included in the scope of protection of one or more embodiments of this specification.

Claims (24)

  1. 一种智能合约部署方法,包括:A smart contract deployment method, including:
    获取使用工作流描述语言对工作流进行描述而生成的任务代码;Obtain the task code generated by using the workflow description language to describe the workflow;
    通过编译器对所述任务代码进行编译,生成用于表征所述工作流的合约代码;compiling the task code by a compiler to generate a contract code for representing the workflow;
    向区块链网络发送用于部署所述合约代码的区块链交易,以在所述区块链网络中部署相应的智能合约,所述智能合约用于在被调用时根据所述工作流中各任务结点所定义的业务逻辑向参与所述区块链网络的节点成员分配待执行任务。Send a block chain transaction for deploying the contract code to the block chain network, so as to deploy the corresponding smart contract in the block chain network, and the smart contract is used to The business logic defined by each task node assigns tasks to be executed to the node members participating in the blockchain network.
  2. 根据权利要求1所述的方法,获取所述任务代码,包括:According to the method according to claim 1, obtaining the task code comprises:
    接收客户端发送的所述任务代码;或者,receiving said task code sent by the client; or,
    根据客户端对预定义的任务模板提供的配置信息,生成所述任务代码。The task code is generated according to the configuration information provided by the client for the predefined task template.
  3. 根据权利要求1所述的方法,所述对所述任务代码进行编译,包括下述之一:The method according to claim 1, said compiling said task code comprises one of the following:
    将所述任务代码编译为高级语言编写的合约代码;Compile the task code into a contract code written in a high-level language;
    将所述任务代码编译为字节码,并将所述字节码作为所述合约代码;compiling the task code into bytecode, and using the bytecode as the contract code;
    先将所述任务代码编译为高级语言编写的代码,再将所述高级语言编写的代码进一步编译为字节码,并将所述字节码作为所述合约代码。The task code is first compiled into a code written in a high-level language, and then the code written in the high-level language is further compiled into a bytecode, and the bytecode is used as the contract code.
  4. 根据权利要求3所述的方法,在所述合约代码由高级语言编写的情况下,所述在所述区块链网络中部署相应的智能合约,包括:According to the method according to claim 3, when the contract code is written in a high-level language, deploying the corresponding smart contract in the blockchain network includes:
    将所述合约代码编译为字节码,并在所述区块链网络中部署该字节码;或者,Compile the contract code into bytecode and deploy the bytecode in the blockchain network; or,
    在所述区块链网络中部署所述高级语言编写的所述合约代码,并在部署完成后立即开始将所述合约代码编译为字节码。Deploy the contract code written in the high-level language in the block chain network, and start compiling the contract code into byte code immediately after the deployment is completed.
  5. 一种智能合约部署方法,应用于区块链网络中的区块链节点,包括:A smart contract deployment method applied to blockchain nodes in a blockchain network, including:
    响应于接收到的部署合约代码的区块链交易,在所述区块链网络中部署相应的智能合约;所述合约代码由编译器对任务代码进行编译而生成,所述任务代码由工作流描述语言对工作流进行描述而生成;In response to the received blockchain transaction of deploying the contract code, deploy the corresponding smart contract in the blockchain network; the contract code is generated by compiling the task code by the compiler, and the task code is generated by the workflow The description language is generated by describing the workflow;
    响应于接收到的调用所述智能合约的区块链交易,根据所述工作流中各任务结点所定义的业务逻辑向参与所述区块链网络的节点成员分配待执行任务。In response to the received blockchain transaction invoking the smart contract, according to the business logic defined by each task node in the workflow, tasks to be executed are assigned to the node members participating in the blockchain network.
  6. 根据权利要求5所述的方法,还包括:The method according to claim 5, further comprising:
    在所述工作流的处理进度处于第一任务结点之前且第一交易提供的入参使第一任务结点的执行条件被满足的情况下,生成包含第一任务结点所对应第一待执行任务的任务分配事件。When the processing progress of the workflow is before the first task node and the input parameters provided by the first transaction satisfy the execution conditions of the first task node, generate the first task node corresponding to the first task node A task assignment event that executes a task.
  7. 根据权利要求6所述的方法,所述执行条件包括下述至少之一:The method according to claim 6, the execution conditions include at least one of the following:
    第一交易提供的入参的数据格式符合要求;The data format of the input parameters provided by the first transaction meets the requirements;
    第一交易提供的入参为所述工作流中处于第一任务结点之前的第二任务结点所对应的第二待执行任务的执行结果。The input parameter provided by the first transaction is the execution result of the second task to be executed corresponding to the second task node before the first task node in the workflow.
  8. 根据权利要求6所述的方法,所述区块链节点对应的节点设备上部署有区块链节点实例和业务实例,所述区块链节点实例用于生成所述任务分配事件,所述业务实例用于在监听到所述任务分配事件且确定自身所在节点设备所属的区块链成员为所述第一待执行任务的执行方的情况下,参与执行所述第一待执行任务。According to the method according to claim 6, a block chain node instance and a service instance are deployed on the node device corresponding to the block chain node, and the block chain node instance is used to generate the task assignment event, and the service instance The instance is used to participate in the execution of the first task to be executed when the task assignment event is monitored and the block chain member to which the node device is located is determined to be the executor of the first task to be executed.
  9. 根据权利要求8所述的方法,所述第一待执行任务存在多个执行方,各执行方对应的业务实例分别执行所述第一待执行任务,或者各执行方对应的业务实例分别执行所述第一待执行任务包含的多个子任务。According to the method according to claim 8, there are multiple executors in the first task to be executed, and the business instances corresponding to each executor respectively execute the first to-be-executed task, or the business instances corresponding to each executor respectively execute the Multiple subtasks included in the first to-be-executed task.
  10. 根据权利要求8所述的方法,任一执行方对应的业务实例执行任一任务,包括:According to the method according to claim 8, the business instance corresponding to any executor performs any task, including:
    所述业务实例调用部署于自身所在节点设备本地的计算资源执行所述任一任务;和/或,The service instance invokes the local computing resource deployed on the node device where it is located to execute any of the tasks; and/or,
    所述业务实例调用部署于自身所在节点设备之外的计算资源执行所述任一任务。The service instance invokes computing resources deployed outside the node device where it is located to execute any of the tasks.
  11. 根据权利要求8所述的方法,任一节点设备中部署的所述区块链节点实例和所 述业务实例处于不同进程。According to the method according to claim 8, the block chain node instance and the service instance deployed in any node device are in different processes.
  12. 根据权利要求6所述的方法,所述区块链节点对应的节点设备上部署有所述区块链网络的网络节点实例和所述区块链网络所管理的区块链子网的子网节点实例,所述子网节点实例在监听到所述任务分配事件且确定自身对应的子网节点成员为所述第一待执行任务的执行方的情况下,在所述区块链子网上提交子网交易,以由自身对应的子网节点成员参与执行所述第一待执行任务。According to the method according to claim 6, the node device corresponding to the blockchain node is deployed with a network node instance of the blockchain network and a subnetwork node of the blockchain subnet managed by the blockchain network Instance, when the subnetwork node instance listens to the task allocation event and determines that its corresponding subnetwork node member is the executor of the first task to be executed, it submits the subnetwork on the block chain subnetwork transaction, so that its corresponding subnetwork node members participate in executing the first task to be executed.
  13. 根据权利要求6所述的方法,还包括:The method of claim 6, further comprising:
    在监听到所述任务分配事件且确定自身对应的区块链节点成员为所述第一待执行任务的执行方的情况下,在自身所在节点设备中创建子网节点实例,并与所述第一待执行任务的其他执行方所创建的子网节点实例组建区块链子网;When the task allocation event is monitored and the block chain node member corresponding to itself is determined to be the executor of the first to-be-executed task, create a subnetwork node instance in the node device where it is located, and communicate with the second A subnetwork node instance created by other executors of the task to be executed to form a blockchain subnetwork;
    在组建的所述区块链子网上提交子网交易,以由自身对应的区块链节点成员执行所述第一待执行任务。Submitting a subnetwork transaction on the established blockchain subnet, so that its corresponding blockchain node members can execute the first task to be executed.
  14. 根据权利要求13所述的方法,所述子网交易包括用于调用所述智能合约的交易。The method of claim 13, the subnetwork transactions include transactions for invoking the smart contracts.
  15. 根据权利要求13所述的方法,所述第一待执行任务的执行方在所述区块链子网中对应的子网节点均为共识节点,所述子网交易通过所述区块链子网的共识后,被各子网节点分别执行。According to the method according to claim 13, the subnet nodes corresponding to the executor of the first task to be executed in the block chain subnet are all consensus nodes, and the subnet transactions pass through the block chain subnet After consensus, it is executed by each subnetwork node.
  16. 根据权利要求13所述的方法,所述第一待执行任务包括多个子任务,所述第一待执行任务的执行方在所述区块链子网中对应的子网节点均为非共识节点,所述子网交易不经过所述区块链子网的共识,并由各子网节点分别执行不同的子任务。According to the method according to claim 13, the first task to be executed includes a plurality of subtasks, and the subnetwork nodes corresponding to the executor of the first task to be executed in the blockchain subnetwork are all non-consensus nodes, The sub-network transactions do not go through the consensus of the block chain sub-network, and each sub-network node performs different sub-tasks respectively.
  17. 根据权利要求8-16中任一项所述的方法,任一区块链节点确定自身对应的区块链节点成员为所述第一待执行任务的执行方,包括:According to the method according to any one of claims 8-16, any blockchain node determines that its corresponding blockchain node member is the executor of the first task to be executed, including:
    所述任务分配事件中包含所述任一区块链节点对应的区块链节点成员的身份信息;或者,The task assignment event includes the identity information of the blockchain node member corresponding to any blockchain node; or,
    第一待执行任务的任务内容匹配于所述任一区块链节点对应的区块链节点成员对应的任务分配条件。The task content of the first to-be-executed task matches the task allocation conditions corresponding to the blockchain node members corresponding to any one of the blockchain nodes.
  18. 根据权利要求9或16所述的方法,各子任务的执行方分别按照所述工作流中定义的执行顺序执行各子任务。According to the method according to claim 9 or 16, the executor of each subtask respectively executes each subtask according to the execution sequence defined in the workflow.
  19. 根据权利要求5所述的方法,还包括:The method according to claim 5, further comprising:
    在所述工作流的处理进度处于第一任务结点之前且第一交易提供的入参使第一任务结点的执行条件被满足的情况下,所述区块链节点实例将所述工作流的处理进度更新至第一任务结点之后。When the processing progress of the workflow is ahead of the first task node and the input provided by the first transaction makes the execution condition of the first task node satisfied, the blockchain node instance converts the workflow The processing progress of is updated after the first task node.
  20. 根据权利要求5所述的方法,所述待执行任务的任一执行方还用于:According to the method according to claim 5, any executor of the task to be executed is also used for:
    调用所述智能合约中的任务回调方法,将所述待执行任务的执行结果返回至所述智能合约。Invoke the task callback method in the smart contract, and return the execution result of the task to be executed to the smart contract.
  21. 一种智能合约部署装置,包括:A smart contract deployment device, comprising:
    代码获取单元,使获取使用工作流描述语言对工作流进行描述而生成的任务代码;A code acquiring unit, configured to acquire task codes generated by describing the workflow using a workflow description language;
    代码编译单元,使通过编译器对所述任务代码进行编译,生成用于表征所述工作流的合约代码;A code compiling unit, which compiles the task code through a compiler to generate a contract code for representing the workflow;
    交易部署单元,使向区块链网络发送用于部署所述合约代码的区块链交易,以在所述区块链网络中部署相应的智能合约,所述智能合约用于在被调用时根据所述工作流中各任务结点所定义的业务逻辑向参与所述区块链网络的节点成员分配待执行任务。The transaction deployment unit is configured to send a block chain transaction for deploying the contract code to the block chain network, so as to deploy the corresponding smart contract in the block chain network, and the smart contract is used to be called according to The business logic defined by each task node in the workflow assigns tasks to be executed to node members participating in the blockchain network.
  22. 一种智能合约部署装置,应用于区块链网络中的区块链节点,包括:A smart contract deployment device applied to blockchain nodes in a blockchain network, including:
    合约部署单元,使响应于接收到的部署合约代码的区块链交易,在所述区块链网络中部署相应的智能合约;所述合约代码由编译器对任务代码进行编译而生成,所述任务代码由工作流描述语言对工作流进行描述而生成;The contract deployment unit is configured to deploy the corresponding smart contract in the blockchain network in response to the received blockchain transaction of deploying the contract code; the contract code is generated by compiling the task code by the compiler, and the The task code is generated by describing the workflow in the workflow description language;
    合约调用单元,使响应于接收到的调用所述智能合约的区块链交易,根据所述工作流中各任务结点所定义的业务逻辑向参与所述区块链网络的节点成员分配待执行任务。The contract invoking unit is configured to assign the node members participating in the blockchain network to be executed according to the business logic defined by each task node in the workflow in response to the received blockchain transaction calling the smart contract. Task.
  23. 一种电子设备,包括:An electronic device comprising:
    处理器;processor;
    用于存储处理器可执行指令的存储器;memory for storing processor-executable instructions;
    其中,所述处理器通过运行所述可执行指令以实现如权利要求1-20中任一项所述的方法。Wherein, the processor implements the method according to any one of claims 1-20 by running the executable instructions.
  24. 一种计算机可读存储介质,其上存储有计算机指令,该指令被处理器执行时实现如权利要求1-20中任一项所述方法的步骤。A computer-readable storage medium, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method according to any one of claims 1-20 are implemented.
PCT/CN2022/093802 2021-06-02 2022-05-19 Smart contract deployment method and apparatus WO2022252995A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110611555.X 2021-06-02
CN202110611555.XA CN113067900B (en) 2021-06-02 2021-06-02 Intelligent contract deployment method and device

Publications (1)

Publication Number Publication Date
WO2022252995A1 true WO2022252995A1 (en) 2022-12-08

Family

ID=76568499

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/093802 WO2022252995A1 (en) 2021-06-02 2022-05-19 Smart contract deployment method and apparatus

Country Status (2)

Country Link
CN (1) CN113067900B (en)
WO (1) WO2022252995A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116737348A (en) * 2023-08-14 2023-09-12 腾讯科技(深圳)有限公司 Multi-party task processing method and device, computer equipment and storage medium

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113067900B (en) * 2021-06-02 2021-09-24 支付宝(杭州)信息技术有限公司 Intelligent contract deployment method and device
CN114527712A (en) * 2021-11-22 2022-05-24 广东嘉腾机器人自动化有限公司 AGV task modification method and modification system
CN114726858A (en) * 2022-03-31 2022-07-08 蚂蚁区块链科技(上海)有限公司 Data processing method and device, electronic equipment and storage medium
CN115759955B (en) * 2022-10-20 2023-08-04 福建师范大学 Business process execution engine based on blockchain

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104246702A (en) * 2012-07-16 2014-12-24 惠普发展公司,有限责任合伙企业 Workflow compilation
CN109359957A (en) * 2018-09-17 2019-02-19 中国银联股份有限公司 A kind of method and relevant apparatus of multi-party computations
US20190205884A1 (en) * 2017-12-28 2019-07-04 International Business Machines Corporation Converting processes into multiple blockchain smart contracts
CN111027936A (en) * 2019-12-10 2020-04-17 杭州趣链科技有限公司 Workflow realization method, equipment and medium based on intelligent contract in alliance network
US10659219B1 (en) * 2019-08-23 2020-05-19 Capital One Services, Llc Workflow management via distributed ledgers and smart contracts
CN111612615A (en) * 2019-02-26 2020-09-01 傲为信息技术(江苏)有限公司 Block chain sub-chain creation method and system based on public chain
CN111770113A (en) * 2020-08-31 2020-10-13 支付宝(杭州)信息技术有限公司 Method for executing intelligent contract, block chain node and node equipment
CN111768187A (en) * 2020-08-31 2020-10-13 支付宝(杭州)信息技术有限公司 Method for deploying intelligent contract, block chain node and storage medium
US20200327498A1 (en) * 2016-03-21 2020-10-15 National Ict Australia Limited Business Process Execution on a Blockchain Platform
US20200409940A1 (en) * 2019-06-27 2020-12-31 Advanced New Technologies Co., Ltd. Implementing a blockchain-based workflow
CN113067900A (en) * 2021-06-02 2021-07-02 支付宝(杭州)信息技术有限公司 Intelligent contract deployment method and device
US20210342329A1 (en) * 2020-05-04 2021-11-04 Salesforce.Com, Inc. System or method to run distributed validation of workflows across a network in a shared distributed ledger in multi-tenant cloud environment

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107147735B (en) * 2017-05-12 2020-08-11 北京博晨技术有限公司 Distributed account book system based on hierarchical structure
CN108647946A (en) * 2018-05-16 2018-10-12 深圳市网心科技有限公司 Intelligent contract processing method and system, audiomonitor and storage medium
BR112022003989A2 (en) * 2019-09-06 2022-05-31 Bosonic Inc System and method for providing a blockchain-based registration process
CN111930487A (en) * 2020-08-28 2020-11-13 北京百度网讯科技有限公司 Job flow scheduling method and device, electronic equipment and storage medium

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104246702A (en) * 2012-07-16 2014-12-24 惠普发展公司,有限责任合伙企业 Workflow compilation
US20200327498A1 (en) * 2016-03-21 2020-10-15 National Ict Australia Limited Business Process Execution on a Blockchain Platform
US20190205884A1 (en) * 2017-12-28 2019-07-04 International Business Machines Corporation Converting processes into multiple blockchain smart contracts
CN109359957A (en) * 2018-09-17 2019-02-19 中国银联股份有限公司 A kind of method and relevant apparatus of multi-party computations
CN111612615A (en) * 2019-02-26 2020-09-01 傲为信息技术(江苏)有限公司 Block chain sub-chain creation method and system based on public chain
US20200409940A1 (en) * 2019-06-27 2020-12-31 Advanced New Technologies Co., Ltd. Implementing a blockchain-based workflow
US10659219B1 (en) * 2019-08-23 2020-05-19 Capital One Services, Llc Workflow management via distributed ledgers and smart contracts
CN111027936A (en) * 2019-12-10 2020-04-17 杭州趣链科技有限公司 Workflow realization method, equipment and medium based on intelligent contract in alliance network
US20210342329A1 (en) * 2020-05-04 2021-11-04 Salesforce.Com, Inc. System or method to run distributed validation of workflows across a network in a shared distributed ledger in multi-tenant cloud environment
CN111770113A (en) * 2020-08-31 2020-10-13 支付宝(杭州)信息技术有限公司 Method for executing intelligent contract, block chain node and node equipment
CN111768187A (en) * 2020-08-31 2020-10-13 支付宝(杭州)信息技术有限公司 Method for deploying intelligent contract, block chain node and storage medium
CN113067900A (en) * 2021-06-02 2021-07-02 支付宝(杭州)信息技术有限公司 Intelligent contract deployment method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
GAO YE: "Research on Smart Contract Optimization Method of Business Process Based on Blockchain", CHINESE DOCTORAL DISSERTATIONS FULL-TEXT DATABASE (ELECTRONIC JOURNAL), 31 January 2020 (2020-01-31), XP093010178 *
ZHOU SHUAI: "Design and Implementation of Blockchain Network Management", CHINESE DOCTORAL DISSERTATIONS FULL-TEXT DATABASE (ELECTRONIC JOURNAL), 31 July 2020 (2020-07-31), XP093010174 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116737348A (en) * 2023-08-14 2023-09-12 腾讯科技(深圳)有限公司 Multi-party task processing method and device, computer equipment and storage medium
CN116737348B (en) * 2023-08-14 2024-01-02 腾讯科技(深圳)有限公司 Multi-party task processing method and device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN113067900B (en) 2021-09-24
CN113067900A (en) 2021-07-02

Similar Documents

Publication Publication Date Title
WO2022252995A1 (en) Smart contract deployment method and apparatus
CN113098983B (en) Task execution method and device based on intelligent contract
CN113067904B (en) Method for building block chain sub-network and block chain system
CN113098982B (en) Block chain message transmission method and device
CN113067897B (en) Cross-chain interaction method and device
CN113067895B (en) Method for building block chain sub-network and block chain system
CN113067901B (en) Method for creating block chain subnet
WO2022252996A1 (en) Method for scheduling computing service for service flow contract
CN113067914B (en) Method and device for distributing subnet identification, electronic equipment and storage medium
CN113259457B (en) Information synchronization method and device for block chain sub-network
CN113326290B (en) Cross-network query control method
CN113259464A (en) Method for building block chain sub-network and block chain system
WO2023207076A1 (en) Method and apparatus for establishing blockchain subnet
WO2022252993A1 (en) Off-chain computation service-based service execution method
CN113259462B (en) Block chain message distribution method and device
CN113259119B (en) Block chain message distribution method and device
CN113259466B (en) Block chain subnet operation state control method and block chain system
CN113259459B (en) Block chain subnet operation state control method and block chain system
CN114710492A (en) Method and device for establishing direct connection channel
CN114363162A (en) Block chain log generation method and device, electronic equipment and storage medium
CN114363349B (en) Block chain sub-network starting method and device
CN113098984B (en) Method for forming multi-layer block chain system based on registration mechanism and block chain system
CN114297171A (en) Account data reading and writing method and device
CN114357080A (en) Account data reading and writing method and device
CN116032924A (en) Cross-chain interaction method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22815042

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE