WO2023231342A1 - Method and apparatus for automatically executing contract on the basis of variable state - Google Patents
Method and apparatus for automatically executing contract on the basis of variable state Download PDFInfo
- Publication number
- WO2023231342A1 WO2023231342A1 PCT/CN2022/135342 CN2022135342W WO2023231342A1 WO 2023231342 A1 WO2023231342 A1 WO 2023231342A1 CN 2022135342 W CN2022135342 W CN 2022135342W WO 2023231342 A1 WO2023231342 A1 WO 2023231342A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- callback
- contract
- variable
- list
- transaction
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 74
- 230000004044 response Effects 0.000 claims abstract description 13
- 238000013475 authorization Methods 0.000 claims description 25
- 238000004364 calculation method Methods 0.000 claims description 24
- 230000008859 change Effects 0.000 claims description 15
- 238000004590 computer program Methods 0.000 claims description 13
- 238000012217 deletion Methods 0.000 claims description 2
- 230000037430 deletion Effects 0.000 claims description 2
- 230000006870 function Effects 0.000 description 19
- 230000008569 process Effects 0.000 description 16
- 238000010586 diagram Methods 0.000 description 14
- 238000012545 processing Methods 0.000 description 10
- 230000006872 improvement Effects 0.000 description 9
- 238000005516 engineering process Methods 0.000 description 8
- 239000000047 product Substances 0.000 description 5
- 230000008447 perception Effects 0.000 description 4
- 238000012546 transfer Methods 0.000 description 4
- 238000004422 calculation algorithm Methods 0.000 description 3
- 238000004891 communication Methods 0.000 description 3
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000011161 development Methods 0.000 description 3
- 239000003999 initiator Substances 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 2
- 238000005265 energy consumption Methods 0.000 description 2
- 230000014509 gene expression Effects 0.000 description 2
- 239000000463 material Substances 0.000 description 2
- 230000007246 mechanism Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- OKTJSMMVPCPJKN-UHFFFAOYSA-N Carbon Chemical compound [C] OKTJSMMVPCPJKN-UHFFFAOYSA-N 0.000 description 1
- 108010001267 Protein Subunits Proteins 0.000 description 1
- 230000009471 action Effects 0.000 description 1
- 230000006399 behavior Effects 0.000 description 1
- 239000006227 byproduct Substances 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 229910021389 graphene Inorganic materials 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000002085 persistent effect Effects 0.000 description 1
- 229920001296 polysiloxane Polymers 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 238000012552 review Methods 0.000 description 1
- 239000010979 ruby Substances 0.000 description 1
- 229910001750 ruby Inorganic materials 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4482—Procedural
- G06F9/4484—Executing subprograms
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4498—Finite state machines
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/547—Remote procedure calls [RPC]; Web services
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/604—Tools and structures for managing or administering access control systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/62—Protecting access to data via a platform, e.g. using keys or access control rules
- G06F21/6218—Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
- G06F21/6245—Protecting personal data, e.g. for financial or medical purposes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/54—Indexing scheme relating to G06F9/54
- G06F2209/549—Remote execution
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2221/00—Indexing scheme relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F2221/21—Indexing scheme relating to G06F21/00 and subgroups addressing additional information or applications relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F2221/2141—Access rights, e.g. capability lists, access control lists, access tables, access matrices
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION 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
- G06Q10/00—Administration; Management
- G06Q10/10—Office automation; Time management
- G06Q10/107—Computer-aided management of electronic mailing [e-mailing]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION 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/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/04—Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
Definitions
- the embodiments of this specification belong to the field of blockchain technology, and particularly relate to a method and device for automatically executing a contract based on variable status.
- Blockchain is a new application model of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
- data blocks are combined into a chained data structure in a chronological manner and are cryptographically guaranteed to be an untamperable and unforgeable distributed ledger. Due to the characteristics of blockchain, such as decentralization, non-tamperable information, and autonomy, blockchain has also received more and more attention and applications.
- the blockchain can be understood as a distributed state machine: all nodes start from the same creation state, sequentially run the transactions in the consensus block, and drive the status of each node to follow the same operation sequence (add, delete, modify) Continuously changing to achieve the same state of all nodes after executing transactions in the same numbered block, we call this state the world state.
- the world state records various information, such as account balance, smart contract bytecode, customized data of each smart contract, chain configuration parameters, etc.
- the world state represents the current state, that is, the current value of each recorded state data.
- One or more embodiments of this specification describe a method and device for automatically executing a contract based on variable status.
- a method for automatically executing a contract based on the state of a variable includes: determining that the state of the first variable of the target type has changed based on the execution result of the target transaction, wherein the above target transaction calls the first contract; Determine whether a callback list for the above-mentioned first variable is included in the contract state of the above-mentioned first contract, wherein the callback items in the above-mentioned callback list include callback contract information and callback parameters; in response to determining that a callback for the above-mentioned first variable is included list, execute the callback contract based on the callback parameters of the callback items in the above callback list.
- a device for automatically executing a contract based on the state of a variable includes: a first determination unit configured to determine a change in the state of the first variable of the target type based on the execution result of the target transaction, wherein the above-mentioned The target transaction calls the first contract; the second determination unit is configured to determine whether the callback list for the above-mentioned first variable is included in the contract state of the above-mentioned first contract, wherein the callback items in the above-mentioned callback list include the information of the callback contract and callback parameters; the execution unit is configured to execute the callback contract based on the callback parameters of the callback items in the above-mentioned callback list in response to determining that the callback list contains the above-mentioned first variable.
- a computer-readable storage medium is provided, with a computer program stored thereon.
- the computer program When the above-mentioned computer program is executed in a computer, the computer is caused to perform the method described in any implementation manner in the first aspect.
- a blockchain node including a memory and a processor, characterized in that executable code is stored in the memory, and when the processor executes the executable code, the implementation is as in the first aspect Either implementation describes the method.
- the type of the variable that will affect the execution of the preset operation after the state changes can be declared as a target type, where the target type
- the first variable can be defined through the first contract.
- the node of the blockchain can first determine that the state of the first variable of the target type has changed based on the execution result of the target transaction, and then determine whether a callback list for the first variable is included in the contract state of the first contract.
- Callback items include callback contract information and callback parameters.
- the callback contract is executed based on the callback parameters of the callback item in the callback list, and the preset operation can be performed based on the callback contract, thus achieving timely perception of the target type in the world state.
- the state change of the variable and automatically perform the preset operation based on the change of the state of the variable of the target type.
- Figure 1 shows a blockchain architecture diagram in one embodiment
- Figure 2 shows a schematic diagram of an application scenario in which embodiments of this specification can be applied
- Figure 3 shows a schematic flowchart of a method for automatically executing a contract based on variable status according to one embodiment
- Figure 4 shows a schematic flow chart of an example of registering a callback item for the first variable
- Figure 5 shows a schematic flow chart of an example of a first variable logout callback item
- Figure 6 shows a schematic block diagram of a device for automatically executing a contract based on variable states according to one embodiment.
- FIG. 1 shows a blockchain architecture diagram in an embodiment.
- the blockchain 100 includes, for example, 6 nodes.
- the connections between nodes schematically represent P2P (Peer to Peer, point-to-point) connections.
- P2P Peer to Peer, point-to-point
- These nodes can store the entire ledger, that is, store the status of all blocks and all accounts.
- each node in the blockchain can generate the same state in the blockchain by executing the same transaction, and each node in the blockchain can store the same state database.
- FIG. 1 shows that the blockchain includes 6 nodes, the embodiments of this description are not limited to this, and may include other numbers of nodes.
- the nodes included in the blockchain can meet Byzantine Fault Tolerance (BFT) requirements.
- BFT Byzantine Fault Tolerance
- the mentioned Byzantine fault tolerance requirements can be understood as meaning that Byzantine nodes can exist within the blockchain, but the blockchain does not reflect Byzantine behavior externally.
- some Byzantine fault-tolerant algorithms require the number of nodes to be greater than 3f+1, where f is the number of Byzantine nodes, such as the Practical Byzantine Fault Tolerance algorithm PBFT (Practical Byzantine Fault Tolerance).
- Transactions in the blockchain field can refer to task units that are executed and recorded in the blockchain. Transactions usually include sending fields (From), receiving fields (To) and data fields (Data). Among them, when the transaction is a transfer transaction, the From field represents the account address that initiated the transaction (that is, initiated a transfer task to another account), the To field represents the account address that received the transaction (that is, received the transfer), and the Data field Include transfer amount.
- the From field indicates the account address that initiated the transaction
- the To field indicates the account address of the contract called by the exchange
- the Data field includes the function name in the calling contract and the corresponding Data such as the incoming parameters of the function are used to obtain the code of the function from the blockchain and execute the code of the function when the transaction is executed.
- Smart contracts on the blockchain are contracts that can be triggered and executed by transactions on the blockchain system.
- Smart contracts can be defined in the form of code. Calling a smart contract in Ethereum is to initiate a transaction pointing to the smart contract address, allowing each node in the Ethereum network to run the smart contract code in a distributed manner.
- smart contracts can also be set by the system in the genesis block. This type of contract is generally called a creation contract.
- some blockchain data structures, parameters, properties and methods can be set in the genesis contract.
- accounts with system administrator rights can create system-level contracts or modify system-level contracts (referred to as system contracts). Among them, the system contract can be used to add data structures for different business data in the blockchain.
- Bob sends a transaction containing information about creating a smart contract (i.e., deploying the contract) to the blockchain as shown in Figure 1.
- the data field of the transaction includes the code of the contract to be created (such as bytecode or machine code), the to field of the transaction is empty to indicate that the transaction is used to deploy the contract.
- the contract address "0x6f8ae93" of the contract is determined.
- Each node adds the contract account corresponding to the contract address of the smart contract in the state database, allocates the state storage corresponding to the contract account, and stores The contract code is saved in the state storage of the contract, so the contract is created successfully.
- each node in the blockchain can execute the transaction respectively, thereby executing the contract respectively, and update the status database based on the execution of the contract.
- the data authorization adding function of the workflow contract corresponding to privacy computing also needs to check whether the required data access authorization has been obtained after adding authorization based on the transaction, and when the authorization meets the requirements Then, take the initiative as the workflow initiator to start the workflow contract during the execution of this transaction.
- This solution requires writing the logic of automatically starting the workflow contract according to the authorization addition status into the contract body, which is not flexible enough and cannot cope with unexpected functional requirements during contract development.
- the blockchain supports querying the authorization status obtained by the workflow contract through transactions.
- the workflow initiator regularly calls the query interface externally. After determining that the workflow contract has obtained sufficient authorization, a transaction is sent to start the workflow.
- This solution requires external polling to query the authorization status periodically through transactions, which lacks real-time performance and also causes high energy consumption in computing.
- embodiments of this specification provide a method for automatically executing a contract based on the state of variables, thereby realizing timely perception of state changes of variables in the world state and automatically executing preset operations based on changes in variable state.
- FIG. 2 shows a schematic diagram of an application scenario in which the embodiments of this specification can be applied.
- This application scenario can be a scenario of privacy computing based on the blockchain.
- the corresponding privacy calculation can be started. That is to say, the value of variable N1 used to represent the amount of authorized data will affect the execution of the corresponding operations of privacy calculation after change. Therefore, when defining variable N1 through contract C1, declare the type of variable N1 as the target type, and The information of variable N1 is stored in the contract state of contract C1. As an example, you could allow the user to query the state of a variable of a target type in the world state.
- the node of the blockchain can receive the transaction Tx1 sent by the caller B to register the callback item.
- the transaction Tx1 can call the contract C1.
- the transaction Tx1 can include the variable name of the variable N1, the callback parameters of the callback contract and the information of the callback contract (such as , the contract address of the callback contract).
- the callback contract can be used to determine whether the variable N1 at the current moment exceeds the preset quantity threshold.
- the workflow contract used for privacy calculations is called to perform related privacy calculation operations.
- the node of the blockchain can execute transaction Tx1 and add a callback item to the callback list preset for variable N1.
- the callback item can include the information of the callback contract, the account of caller B and the callback parameters of the callback contract.
- the callback list corresponding to variable N1 can be stored in the contract state of contract C1.
- data owner A can send a target transaction for uploading authorization information to the node of the blockchain, and the target transaction can call contract C1.
- the nodes of the blockchain can receive and execute the target transaction sent by the data owner A, and determine the change in the state of the target type variable N1 based on the execution result of the target transaction.
- the node of the blockchain can determine whether the callback list for variable N1 is included in the contract status of contract C1.
- the callback items in the callback list can include callback contract information and callback parameters. If the contract status of contract C1 includes a callback list for variable N1, the callback contract is executed based on the callback parameters of the callback items in the callback list.
- the callback contract can determine whether the value of variable N1 at the current moment exceeds the preset quantity threshold. If it exceeds, the workflow contract used for privacy calculation will be called to perform related privacy calculation operations. This achieves timely perception of changes in variable N1, and automatically calls the workflow contract corresponding to privacy computing based on changes in the world state of variable N1 to perform privacy computing operations.
- This method does not need to specify the actions that need to be performed after the world state of variable N1 changes in the contract body of the workflow contract corresponding to the privacy calculation. Instead, the caller B can customize it by registering a callback item, which is flexible. In addition, this method does not require external polling to query the value of variable N1 periodically through transactions, thus saving energy consumption.
- FIG. 3 shows a schematic flowchart of a method for automatically executing a contract based on variable status according to one embodiment. It can be understood that this method can be performed by nodes of the blockchain, and the nodes of the blockchain can be implemented by any device, equipment, equipment cluster, etc. with computing and processing capabilities.
- the method of automatically executing a contract based on variable status can include the following steps:
- Step 301 Determine a change in the state of the first variable of the target type based on the execution result of the target transaction.
- the node of the blockchain can receive and execute the target transaction sent by the user. After executing the target transaction, the node of the blockchain can determine the state of the first variable of the target type based on the execution result of the target transaction. changes happened. That is to say, the execution result of the target transaction will change the state of the first variable of the target type in the world state.
- the first variable of the target type can be defined in advance through the first contract.
- the type of the first variable can be declared as the target type, and the information of the first variable ( For example, variable values, variable names, attributes, etc.) are stored in the contract state of the first contract.
- the above target transaction can call the first contract to change the variable value of the first variable recorded in the contract state of the first contract.
- the user can register a callback item for the first variable in the callback list preset for the first variable, where the callback list for the first variable can be stored In the contract state of the first contract.
- the user can be the caller who calls the callback contract.
- the node of the blockchain can automatically execute the callback contract based on the state of the first variable in the current world state. For example, when it is determined that the state of the first variable in the contract state of the first contract changes after a transaction is executed, The callback items in the callback list pre-registered by the user for the first variable can be called.
- Figure 4 shows a schematic flow chart of an example of registering a callback item for the first variable.
- the callback item can be registered for the first variable in the following way:
- the caller of the callback contract can send the first transaction for registering the callback item to the blockchain.
- the first transaction may include the variable name of the first variable, information about the callback contract, and callback parameters of the callback contract.
- the information of the callback contract can include the code of the callback contract, the address of the callback contract, etc.
- the callback parameters can refer to the parameters used when calling the callback contract.
- the caller can set the callback parameters of the callback contract according to actual business needs, and define the corresponding business logic in the callback contract, that is, define the operations to be performed corresponding to the state change of the first variable. For example, in the business scenario of privacy computing, assuming that the first variable is the amount of data access authorization in privacy computing, the callback contract can be used to determine whether the amount of data access authorization at the current moment exceeds the preset quantity threshold.
- the preset workflow contract is called, which can be used to perform privacy calculation-related operations.
- the contract address of the workflow contract corresponding to privacy calculation can be defined in the callback contract, as well as the business logic of the corresponding workflow contract that calls privacy calculation.
- the business logic can be to call privacy when the amount of authorized data exceeds the preset value.
- the calculated corresponding workflow contract can be defined in the callback contract.
- the business logic can be that when the account balance is less than the preset value, a mailbox corresponding to the account will be sent. Automatically send emails with preset content.
- the node of the blockchain can receive the first transaction sent by the caller for registering the callback item, and the first transaction can call the first contract.
- the node of the blockchain can execute the first transaction and add a callback item to the callback list preset for the first variable.
- the node of the blockchain can execute the first transaction, call the first contract, and add a callback item to the callback list preset for the first variable.
- the callback item can include the information of the callback contract, the caller Account, callback parameters of the callback contract, etc.
- the callback list for the first variable can be stored in the contract state of the first contract. It can be understood that when a caller registers a callback item for the first variable, the callback list will be set for the first variable. If no callback item is registered by the caller for the first variable, or the callback item registered for the first variable is then unregistered, the callback list does not need to be set for the first variable.
- the caller can set a callback item for the first variable according to actual business needs, and define the operations to be performed for the state change of the first variable in the callback contract included in the callback item.
- This method customizes the operation to be performed when the state of the first variable changes by registering a callback item without modifying other existing contracts related to the business, so it is flexible.
- Figure 5 shows a schematic flow chart of an example of a first variable logout callback item.
- the caller can also unregister the callback item registered for the first variable in the following way:
- the caller of the callback contract can send a second transaction for canceling the callback item to the blockchain.
- the second transaction may include the caller's account and the variable name of the first variable.
- the node of the blockchain can receive the second transaction sent by the caller to cancel the callback item, and the second transaction can call the first contract.
- the node of the blockchain can execute the second transaction and delete the callback item containing the caller's account from the callback list corresponding to the first variable.
- the node of the blockchain can execute the second transaction to call the first contract, and delete the callback item containing the caller's account from the callback list corresponding to the first variable.
- the node of the blockchain can search the callback list for the first variable in the contract state of the first contract based on the variable name of the first variable included in the second transaction, and then delete the callback list containing The callback item for the caller's account.
- the caller can delete the callback items previously set for the first variable according to actual business needs, thereby realizing flexible setting of callback items.
- Step 302 Determine whether the contract state of the first contract contains a callback list for the first variable.
- the node of the blockchain can determine whether the callback list for the first variable is included in the contract state of the first contract.
- the callback list can include callback items
- the callback items can include callback contract information, callback parameters, etc.
- Step 303 In response to determining that the callback list for the first variable is included, execute the callback contract based on the callback parameters of the callback items in the callback list.
- the node of the blockchain determines that the contract state of the first contract contains a callback list for the first variable, the node of the blockchain can execute based on the callback parameters of the callback items in the callback list.
- Callback contract the callback list for the first variable may include one or more callback items. For example, it may include one callback item registered by one caller, or may include multiple callback items registered by multiple callers.
- executing the callback contract based on the callback parameters of the callback item in the callback list in step 303 can be performed as follows: after the target transaction is executed, based on the callback parameters of the callback item in the callback list, execute The callback contract corresponding to the callback contract information included in the callback item.
- the callback contract corresponding to the callback item contained in the callback list of the first variable can be executed immediately after the execution of the target transaction is completed.
- the above-mentioned target transaction may be a transaction in a target block
- the target block may be a consensus block
- the target block may include one or more transactions.
- the callback contract can be executed as follows:
- the nodes of the blockchain can determine whether the multiple transactions contained in the target block at the current moment have been completed.
- variable name of the first variable can be added to the preset to-be-called list.
- the callback item of the callback list of the corresponding variable is Determine the corresponding callback contract and callback parameters, and call the corresponding callback contract through the determined callback parameters.
- the node of the blockchain can determine whether the multiple transactions in the target block at the current moment have been completed. If multiple transactions in the target block are not all executed, the variable name of the first variable can be added to the preset to-be-called list.
- the to-be-called list can include one or more variables of the target type. variable name. If multiple transactions in the target block are executed, then after adding the variable name of the first variable to the to-be-called list, the corresponding callback contract can be executed based on the variable name of at least one variable included in the to-be-called list.
- the node of the blockchain can query the callback list of the first variable from the contract status of the first contract based on the variable name of the first variable, and then determine the corresponding callback item from the callback list of the first variable. callback contract and callback parameters, and call the corresponding callback contract through the determined callback parameters.
- the callback contract can be executed after multiple transactions in the target block have been executed, thereby increasing the flexibility of callback contract execution.
- the nodes of the blockchain can also sort the callback items corresponding to the variable names contained in the to-be-called list.
- the node of the blockchain can first obtain the callback items in the callback list of the variable corresponding to the variable name in the to-be-called list, and then sort the obtained call items in various ways, such as random ordering.
- the nodes of the blockchain can execute each callback item in the order according to the sorting result. Specifically, for a certain callback item, the corresponding callback item can be called based on the callback parameter of the callback item. Callback contract.
- the callback items in the callback list of the target type variable can also include the callback priority in addition to the callback contract information, callback parameters, etc.
- the callback priority can be set by the caller when registering the callback item.
- the caller can set the fee that it is willing to pay for executing the callback contract when registering the callback item. The higher the fee, the higher the priority.
- the nodes of the blockchain can determine the priority of callback items based on the level of payment.
- the above-mentioned sorting of the callback items corresponding to the variable names contained in the to-be-called list can be performed as follows: According to the callback priority of the callback items corresponding to each variable name in the to-be-called list, each variable name included in the to-be-called list is sorted The corresponding callback items are sorted. For example, you can sort callbacks from high to low priority. In this implementation, the execution order of the callback items corresponding to the variable names in the to-be-called list can be controlled based on the callback priority of the callback item.
- the hash can be calculated based on the callback contract of the callback item corresponding to each variable name in the to-be-called list, the callback party account, and the block number of the target block where the target transaction is located. It can be understood that in practice, the information used to calculate the hash can also be determined according to actual needs, and is not limited to the use of callback contracts, callback party accounts and block numbers.
- the hash can be calculated using the callback contract and the callback party account. For another example, you can also use the callback contract, the callback party account and the registration time of the callback item to calculate the hash and so on.
- the callback items corresponding to the variable names contained in the to-be-called list are sorted. For example, you can sort the hash calculation results from large to small or from small to large.
- the execution order of the callback items corresponding to the variable names in the to-be-called list can be determined based on hash calculation.
- the type of the first variable that will affect the execution of the preset operation after the state changes can be declared as the target type, where the first variable of the target type can Defined by the first contract.
- the node of the blockchain can first determine that the state of the first variable of the target type has changed based on the execution result of the target transaction, and then determine whether a callback list for the first variable is included in the contract state of the first contract.
- Callback items include callback contract information and callback parameters.
- the callback contract is executed based on the callback parameters of the callback item in the callback list, and the preset operation can be performed based on the callback contract, thus achieving timely perception of the target type in the world state.
- the state change of the variable and automatically perform the preset operation based on the change of the state of the variable of the target type.
- an apparatus for automatically executing a contract based on the state of a variable is provided.
- the above-mentioned device for automatically executing contracts based on variable states can be deployed on the nodes of the blockchain.
- the nodes of the blockchain can be implemented by any device, equipment, equipment cluster, etc. with computing and processing capabilities.
- Figure 6 shows a schematic block diagram of a device for automatically executing a contract based on variable states according to one embodiment.
- the device 600 for automatically executing a contract based on variable status includes: a first determination unit 601 configured to determine that the status of the first variable of the target type has changed based on the execution result of the target transaction, wherein the above target transaction calls The first contract; the second determination unit 602 is configured to determine whether the callback list for the above-mentioned first variable is included in the contract state of the above-mentioned first contract, wherein the callback items in the above-mentioned callback list include callback contract information and callback parameters. ;
- the execution unit 603 is configured to execute the callback contract based on the callback parameters of the callback items in the above-mentioned callback list in response to determining that the callback list contains the above-mentioned first variable.
- the above-mentioned device 600 further includes: a first receiving unit (not shown in the figure) configured to receive the first transaction sent by the caller for registering a callback item, the above-mentioned first transaction A transaction calls the above-mentioned first contract, wherein the above-mentioned first transaction includes the variable name of the above-mentioned first variable, the callback parameters of the callback contract, and the information of the callback contract; an adding unit (not shown in the figure) is configured to execute the above-mentioned first contract.
- the above-mentioned callback item includes the above-mentioned callback contract information, the above-mentioned caller's account and the above-mentioned callback parameters.
- the above-mentioned device 600 further includes: a second receiving unit (not shown in the figure) configured to receive the second transaction sent by the above-mentioned caller for canceling the callback item, the above-mentioned The second transaction calls the above-mentioned first contract, wherein the above-mentioned second transaction includes the variable name of the above-mentioned first variable; the deletion unit (not shown in the figure) is configured to execute the above-mentioned second transaction.
- the callback items containing the above caller's account are deleted from the callback list.
- the above-mentioned execution unit 603 is further configured to: after the execution of the above-mentioned target transaction is completed, execute the callback contract based on the callback parameters of the callback item in the above-mentioned callback list.
- the above-mentioned target transaction is a transaction in the target block
- the above-mentioned execution unit 603 includes: a variable name adding module (not shown in the figure) configured to respond to determining the current moment If the transaction contained in the above-mentioned target block has not been completed, the variable name of the above-mentioned first variable is added to the preset to-be-called list; the contract calling module (not shown in the figure) is configured to respond to determining the above-mentioned target at the current moment.
- the corresponding callback is determined from the callback items of the callback list of the corresponding variable based on the variable name contained in the above-mentioned to-be-called list. contract and callback parameters, and call the corresponding callback contract through the determined callback parameters.
- the above-mentioned device 600 further includes: a sorting module (not shown in the figure) configured to sort the callback items corresponding to the variable names included in the above-mentioned to-be-called list.
- a sorting module (not shown in the figure) configured to sort the callback items corresponding to the variable names included in the above-mentioned to-be-called list.
- the callback item also includes a callback priority
- the above-mentioned sorting module is further configured to: according to the callback priority of the callback item corresponding to each variable name in the to-be-called list, the above-mentioned to-be-called The callback items corresponding to each variable name contained in the list are sorted.
- the above-mentioned sorting module is further configured to: based on the callback contract of the callback item corresponding to each variable name in the to-be-called list, the callback party account, and the target block in which the target transaction is located. Block number, calculate the hash; according to the hash calculation result, sort the callback items corresponding to the variable names contained in the above to-be-called list.
- the above-mentioned first variable is the data access authorization amount in privacy calculation
- the above-mentioned callback contract is used to determine whether the data access authorization amount at the current moment exceeds a preset quantity threshold.
- the preset workflow contract is called, where the above workflow contract is used to perform operations related to privacy calculations.
- a computer-readable storage medium is also provided, on which a computer program is stored.
- the computer is caused to execute the method described in FIG. 3 .
- a blockchain node including a memory and a processor, characterized in that executable code is stored in the memory, and when the processor executes the executable code, Figure 3 is implemented. method described.
- PLD Programmable Logic Device
- FPGA Field Programmable Gate Array
- HDL Hardware Description Language
- HDL High-Speed Integrated Circuit Hardware Description Language
- ABEL Advanced Boolean Expression Language
- AHDL Altera Hardware Description Language
- HDCal Joint CHDL
- JHDL Java Hardware Description Language
- Lava Lava
- Lola MyHDL
- PALASM RHDL
- Verilog Verilog
- the controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code (eg, software or firmware) executable by the (micro)processor. , logic gates, switches, Application Specific Integrated Circuit (ASIC), programmable logic controllers and embedded microcontrollers.
- controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, For Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the memory's control logic.
- the controller in addition to implementing the controller in the form of pure computer-readable program code, the controller can be completely programmed with logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded logic by logically programming the method steps. Microcontroller, etc. to achieve the same function. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the means for implementing various functions can be considered as structures within hardware components as well as software modules implementing the methods.
- the systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions.
- a typical implementation device is a server system.
- the computer that implements the functions of the above embodiments may be, for example, a personal computer, a laptop computer, a vehicle-mounted human-computer interaction device, a cellular phone, a camera phone, a smart phone, or a personal digital assistant. , media player, navigation device, email device, game console, tablet, wearable device, or a combination of any of these devices.
- the functions are divided into various modules and described separately.
- the functions of each module can be implemented in the same or multiple software and/or hardware, or the modules that implement the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. .
- the device embodiments described above are only illustrative.
- the division of the units is only a logical function division. In actual implementation, there may be other division methods.
- multiple units or components may be combined or integrated. to another system, or some features can be ignored, or not implemented.
- the coupling or direct coupling or communication connection between each other shown or discussed may be through some interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
- These computer program instructions may also be stored in a computer-readable memory that causes a computer or other programmable data processing apparatus to operate in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction means, the instructions
- the device implements the functions specified in a process or processes of the flowchart and/or a block or blocks of the block diagram.
- These computer program instructions may also be loaded onto a computer or other programmable data processing device, causing a series of operating steps to be performed on the computer or other programmable device to produce computer-implemented processing, thereby executing on the computer or other programmable device.
- Instructions provide steps for implementing the functions specified in a process or processes of a flowchart diagram and/or a block or blocks of a block diagram.
- a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
- processors CPUs
- input/output interfaces network interfaces
- memory volatile and non-volatile memory
- Memory may include non-permanent storage in computer-readable media, random access memory (RAM) and/or non-volatile memory in the form of read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
- RAM random access memory
- ROM read-only memory
- flash RAM flash random access memory
- Computer-readable media includes both persistent and non-volatile, removable and non-removable media that can be implemented by any method or technology for storage of information.
- Information may be computer-readable instructions, data structures, modules of programs, 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), and read-only memory.
- PRAM phase change memory
- SRAM static random access memory
- DRAM dynamic random access memory
- RAM random access memory
- read-only memory read-only memory
- ROM read-only memory
- EEPROM electrically erasable programmable read-only memory
- flash memory or other memory technology
- compact disc read-only memory CD-ROM
- DVD digital versatile disc
- Magnetic tape magnetic tape storage, graphene storage or other magnetic storage devices or any other non-transmission medium can be used to store information that can be accessed by a computing device.
- computer-readable media does not include transitory media, such as modulated data signals and carrier waves.
- one or more embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, one or more embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment that combines software and hardware aspects. Furthermore, one or more embodiments of the present description may employ a computer program implemented 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. Product form.
- computer-usable storage media including, but not limited to, disk storage, CD-ROM, optical storage, etc.
- program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types.
- program modules may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network.
- program modules may be located in both local and remote computer storage media including storage devices.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
Provided in the embodiments of the present description are a method and apparatus for automatically executing a contract on the basis of a variable state. A particular embodiment of the method comprises: determining, according to an execution result of a target transaction, that the state of a first variable of a target type is changed, wherein the target transaction calls a first contract; determining whether contract states of the first contract include a callback list for the first variable, wherein callback items in the callback list involve information regarding a callback contract, and callback parameters; and in response to it being determined that the callback list for the first variable is included, executing the callback contract on the basis of the callback parameters, which are comprised in the callback items in the callback list.
Description
本申请要求于2022年5月30日提交中国国家知识产权局、申请号为202210600436.9、申请名称为“基于变量状态自动执行合约的方法和装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on May 30, 2022, with application number 202210600436.9 and the application title "Method and device for automatically executing contracts based on variable status", the entire content of which is incorporated by reference incorporated in this application.
本说明书实施例属于区块链技术领域,尤其涉及一种基于变量状态自动执行合约的方法和装置。The embodiments of this specification belong to the field of blockchain technology, and particularly relate to a method and device for automatically executing a contract based on variable status.
区块链(Blockchain)是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链***中按照时间顺序将数据区块以顺序相连的方式组合成链式数据结构,并以密码学方式保证的不可篡改和不可伪造的分布式账本。由于区块链具有去中心化、信息不可篡改、自治性等特性,区块链也受到人们越来越多的重视和应用。Blockchain is a new application model of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. In the blockchain system, data blocks are combined into a chained data structure in a chronological manner and are cryptographically guaranteed to be an untamperable and unforgeable distributed ledger. Due to the characteristics of blockchain, such as decentralization, non-tamperable information, and autonomy, blockchain has also received more and more attention and applications.
区块链可以理解为一个分布式的状态机:所有节点从同一个创世状态开始,依次运行达成共识的区块内的交易,驱动各个节点的状态按照相同操作序列(增加,删除,修改)不断变化,实现所有节点在执行完相同编号区块内的交易后,状态一致,我们把这个状态称之为世界状态。世界状态里面记录了各种信息,比如账户余额,智能合约字节码,各个智能合约自定义的数据,链的配置参数等。世界状态表示的是当前状态,即记录的各状态数据的当前数值。在一些区块链的应用场景中,有时需要根据世界状态中某些变量的值来执行某些预设操作,例如,在基于区块链的隐私计算过程中,需要世界状态中某些变量的值满足一定的运行条件(比如,收集到足够的数据使用授权)才可以启动对应的隐私计算。针对这些场景,如何及时感知世界状态中变量的变化,并基于世界状态中变量的改变高效执行预设操作具有重要的现实意义和价值。The blockchain can be understood as a distributed state machine: all nodes start from the same creation state, sequentially run the transactions in the consensus block, and drive the status of each node to follow the same operation sequence (add, delete, modify) Continuously changing to achieve the same state of all nodes after executing transactions in the same numbered block, we call this state the world state. The world state records various information, such as account balance, smart contract bytecode, customized data of each smart contract, chain configuration parameters, etc. The world state represents the current state, that is, the current value of each recorded state data. In some blockchain application scenarios, it is sometimes necessary to perform certain preset operations based on the values of certain variables in the world state. For example, in the privacy calculation process based on blockchain, the values of certain variables in the world state are required. Only when the value meets certain operating conditions (for example, sufficient data usage authorization is collected) can the corresponding privacy calculation be started. For these scenarios, how to perceive changes in variables in the world state in a timely manner and efficiently perform preset operations based on changes in variables in the world state has important practical significance and value.
发明内容Contents of the invention
本说明书的一个或多个实施例描述了一种基于变量状态自动执行合约的方法和装置。One or more embodiments of this specification describe a method and device for automatically executing a contract based on variable status.
根据第一方面,提供了一种基于变量状态自动执行合约的方法,上述方法包括:根据目标交易的执行结果确定目标类型的第一变量的状态发生改变,其中,上述目标交易调用第一合约;在上述第一合约的合约状态中确定是否包含针对上述第一变量的回调列表,其中,上述回调列表中的回调项包括回调合约的信息和回调参数;响应于 确定包含针对上述第一变量的回调列表,基于上述回调列表中回调项的回调参数,执行回调合约。According to the first aspect, a method for automatically executing a contract based on the state of a variable is provided. The method includes: determining that the state of the first variable of the target type has changed based on the execution result of the target transaction, wherein the above target transaction calls the first contract; Determine whether a callback list for the above-mentioned first variable is included in the contract state of the above-mentioned first contract, wherein the callback items in the above-mentioned callback list include callback contract information and callback parameters; in response to determining that a callback for the above-mentioned first variable is included list, execute the callback contract based on the callback parameters of the callback items in the above callback list.
根据第二方面,提供了一种基于变量状态自动执行合约的装置,上述装置包括:第一确定单元,配置为根据目标交易的执行结果确定目标类型的第一变量的状态发生改变,其中,上述目标交易调用第一合约;第二确定单元,配置为在上述第一合约的合约状态中确定是否包含针对上述第一变量的回调列表,其中,上述回调列表中的回调项包括回调合约的信息和回调参数;执行单元,配置为响应于确定包含针对上述第一变量的回调列表,基于上述回调列表中回调项的回调参数,执行回调合约。According to a second aspect, a device for automatically executing a contract based on the state of a variable is provided. The device includes: a first determination unit configured to determine a change in the state of the first variable of the target type based on the execution result of the target transaction, wherein the above-mentioned The target transaction calls the first contract; the second determination unit is configured to determine whether the callback list for the above-mentioned first variable is included in the contract state of the above-mentioned first contract, wherein the callback items in the above-mentioned callback list include the information of the callback contract and callback parameters; the execution unit is configured to execute the callback contract based on the callback parameters of the callback items in the above-mentioned callback list in response to determining that the callback list contains the above-mentioned first variable.
根据第三方面,提供了一种计算机可读存储介质,其上存储有计算机程序,当上述计算机程序在计算机中执行时,令计算机执行如第一方面中任一实现方式描述的方法。According to a third aspect, a computer-readable storage medium is provided, with a computer program stored thereon. When the above-mentioned computer program is executed in a computer, the computer is caused to perform the method described in any implementation manner in the first aspect.
根据第四方面,提供了一种区块链的节点,包括存储器和处理器,其特征在于,上述存储器中存储有可执行代码,上述处理器执行上述可执行代码时,实现如第一方面中任一实现方式描述的方法。According to a fourth aspect, a blockchain node is provided, including a memory and a processor, characterized in that executable code is stored in the memory, and when the processor executes the executable code, the implementation is as in the first aspect Either implementation describes the method.
根据本说明书实施例提供的基于变量状态自动执行合约的方法和装置,在使用合约定义变量时,可以将状态改变后会影响预设操作执行的变量的类型声明为目标类型,其中,目标类型的第一变量可以通过第一合约定义。区块链的节点首先可以根据目标交易的执行结果确定目标类型的第一变量的状态发生改变,之后,在第一合约的合约状态中确定是否包含针对第一变量的回调列表,回调列表中的回调项包括回调合约的信息和回调参数。如果确定第一合约的合约状态中包含针对第一变量的回调列表,基于回调列表中回调项的回调参数执行回调合约,基于回调合约可以执行预设操作,从而实现了及时感知世界状态中目标类型的变量的状态变化,并基于目标类型的变量的状态的改变自动执行预设操作。According to the method and device for automatically executing contracts based on variable states provided by embodiments of this specification, when using a contract to define variables, the type of the variable that will affect the execution of the preset operation after the state changes can be declared as a target type, where the target type The first variable can be defined through the first contract. The node of the blockchain can first determine that the state of the first variable of the target type has changed based on the execution result of the target transaction, and then determine whether a callback list for the first variable is included in the contract state of the first contract. Callback items include callback contract information and callback parameters. If it is determined that the contract state of the first contract contains a callback list for the first variable, the callback contract is executed based on the callback parameters of the callback item in the callback list, and the preset operation can be performed based on the callback contract, thus achieving timely perception of the target type in the world state. The state change of the variable, and automatically perform the preset operation based on the change of the state of the variable of the target type.
为了更清楚地说明本说明书实施例的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本说明书中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to explain the technical solutions of the embodiments of this specification more clearly, the drawings needed to be used in the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some of the embodiments recorded in this specification. , for those of ordinary skill in the art, other drawings can also be obtained based on these drawings without exerting creative labor.
图1示出了一个实施例中的区块链架构图;Figure 1 shows a blockchain architecture diagram in one embodiment;
图2示出了本说明书实施例可以应用于其中的一个应用场景的示意图;Figure 2 shows a schematic diagram of an application scenario in which embodiments of this specification can be applied;
图3示出了根据一个实施例的基于变量状态自动执行合约的方法的流程示意图;Figure 3 shows a schematic flowchart of a method for automatically executing a contract based on variable status according to one embodiment;
图4示出了针对第一变量注册回调项的一个例子的流程示意图;Figure 4 shows a schematic flow chart of an example of registering a callback item for the first variable;
图5示出了针对第一变量注销回调项的一个例子的流程示意图;Figure 5 shows a schematic flow chart of an example of a first variable logout callback item;
图6示出了根据一个实施例的基于变量状态自动执行合约的装置的示意性框图。Figure 6 shows a schematic block diagram of a device for automatically executing a contract based on variable states according to one embodiment.
为了使本技术领域的人员更好地理解本说明书中的技术方案,下面将结合本说明书实施例中的附图,对本说明书实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本说明书一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都应当属于本说明书保护的范围。In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this specification. Obviously, the described The embodiments are only some of the embodiments of this specification, but not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by those of ordinary skill in the art without creative efforts should fall within the scope of protection of this specification.
为了进一步说明区块链技术,图1示出了一实施例中的区块链架构图。在图1所示的区块链架构图中,区块链100中例如包含6个节点。节点之间的连线示意性的表示P2P(Peer to Peer,点对点)连接。这些节点上可存储全量的账本,即存储全部区块和全部账户的状态。其中,区块链中的每个节点可通过执行相同的交易而产生区块链中的相同的状态,区块链中的每个节点可存储相同的状态数据库。可以理解,图1中虽然示出了区块链中包括6个节点,本说明书实施例不限于此,而是可以包括其他数目的节点。具体是,区块链中包含的节点可以满足拜占庭容错(Byzantine Fault Tolerance,BFT)要求。所述的拜占庭容错要求可以理解为在区块链内部可以存在拜占庭节点,而区块链对外不体现拜占庭行为。一般的,一些拜占庭容错算法中要求节点个数大于3f+1,f为拜占庭节点个数,例如实用拜占庭容错算法PBFT(Practical Byzantine Fault Tolerance)。To further illustrate blockchain technology, Figure 1 shows a blockchain architecture diagram in an embodiment. In the blockchain architecture diagram shown in Figure 1, the blockchain 100 includes, for example, 6 nodes. The connections between nodes schematically represent P2P (Peer to Peer, point-to-point) connections. These nodes can store the entire ledger, that is, store the status of all blocks and all accounts. Among them, each node in the blockchain can generate the same state in the blockchain by executing the same transaction, and each node in the blockchain can store the same state database. It can be understood that although FIG. 1 shows that the blockchain includes 6 nodes, the embodiments of this description are not limited to this, and may include other numbers of nodes. Specifically, the nodes included in the blockchain can meet Byzantine Fault Tolerance (BFT) requirements. The mentioned Byzantine fault tolerance requirements can be understood as meaning that Byzantine nodes can exist within the blockchain, but the blockchain does not reflect Byzantine behavior externally. Generally, some Byzantine fault-tolerant algorithms require the number of nodes to be greater than 3f+1, where f is the number of Byzantine nodes, such as the Practical Byzantine Fault Tolerance algorithm PBFT (Practical Byzantine Fault Tolerance).
区块链领域中的交易可以指在区块链中执行并记录在区块链中的任务单元。交易中通常包括发送字段(From)、接收字段(To)和数据字段(Data)。其中,在交易为转账交易的情况中,From字段表示发起该交易(即发起对另一个账户的转账任务)的账户地址,To字段表示接收该交易(即接收转账)的账户地址,Data字段中包括转账金额。在交易调用区块链中的智能合约的情况中,From字段表示发起该交易的账户地址,To字段表示交易所调用的合约的账户地址,Data字段中包括调用合约中的函数名、及对该函数的传入参数等数据,以用于在交易执行时从区块链中获取该函数的代码并执行该函数的代码。Transactions in the blockchain field can refer to task units that are executed and recorded in the blockchain. Transactions usually include sending fields (From), receiving fields (To) and data fields (Data). Among them, when the transaction is a transfer transaction, the From field represents the account address that initiated the transaction (that is, initiated a transfer task to another account), the To field represents the account address that received the transaction (that is, received the transfer), and the Data field Include transfer amount. In the case of a transaction calling a smart contract in the blockchain, the From field indicates the account address that initiated the transaction, the To field indicates the account address of the contract called by the exchange, and the Data field includes the function name in the calling contract and the corresponding Data such as the incoming parameters of the function are used to obtain the code of the function from the blockchain and execute the code of the function when the transaction is executed.
区块链中可提供智能合约的功能。区块链上的智能合约是在区块链***上可以被交易触发执行的合约。智能合约可以通过代码的形式定义。在以太坊中调用智能合约,是发起一笔指向智能合约地址的交易,使得以太坊网络中每个节点分布式地运行智能合约代码。需要说明的是,除了可以由用户创建智能合约,也可以在创世块中由***设置智能合约。这类合约一般称为创世合约。一般的,创世合约中可以设置一些区块链的数据结构、参数、属性和方法。此外,具有***管理员权限的账户可以创建***级的合约,或者修改***级的合约(简称为***合约)。其中,所述***合约可用于在区块链中增加不同业务的数据的数据结构。The functions of smart contracts can be provided in the blockchain. Smart contracts on the blockchain are contracts that can be triggered and executed by transactions on the blockchain system. Smart contracts can be defined in the form of code. Calling a smart contract in Ethereum is to initiate a transaction pointing to the smart contract address, allowing each node in the Ethereum network to run the smart contract code in a distributed manner. It should be noted that in addition to smart contracts that can be created by users, smart contracts can also be set by the system in the genesis block. This type of contract is generally called a creation contract. Generally, some blockchain data structures, parameters, properties and methods can be set in the genesis contract. In addition, accounts with system administrator rights can create system-level contracts or modify system-level contracts (referred to as system contracts). Among them, the system contract can be used to add data structures for different business data in the blockchain.
在部署合约的场景中,例如,Bob将一个包含创建智能合约信息(即部署合约) 的交易发送到如图1所示的区块链中,该交易的data字段包括待创建的合约的代码(如字节码或者机器码),交易的to字段为空,以表示该交易用于部署合约。节点间通过共识机制达成一致后,确定合约的合约地址“0x6f8ae93…”,各个节点在状态数据库中添加与该智能合约的合约地址对应的合约账户,分配与该合约账户对应的状态存储,并将合约代码保存在该合约的状态存储中,从而合约创建成功。In the scenario of deploying a contract, for example, Bob sends a transaction containing information about creating a smart contract (i.e., deploying the contract) to the blockchain as shown in Figure 1. The data field of the transaction includes the code of the contract to be created ( Such as bytecode or machine code), the to field of the transaction is empty to indicate that the transaction is used to deploy the contract. After the nodes reach an agreement through the consensus mechanism, the contract address "0x6f8ae93..." of the contract is determined. Each node adds the contract account corresponding to the contract address of the smart contract in the state database, allocates the state storage corresponding to the contract account, and stores The contract code is saved in the state storage of the contract, so the contract is created successfully.
在调用合约的场景中,例如,Bob将一个用于调用智能合约的交易发送到如图1所示的区块链中,该交易的from字段是交易发起方(即Bob)的账户的地址,to字段中的“0x6f8ae93…”代表了被调用的智能合约的地址,交易的data字段包括调用智能合约的方法和参数。在区块链中对该交易进行共识之后,区块链中的各个节点可分别执行该交易,从而分别执行该合约,基于该合约的执行更新状态数据库。In the scenario of calling a contract, for example, Bob sends a transaction for calling a smart contract to the blockchain as shown in Figure 1. The from field of the transaction is the address of the account of the transaction initiator (Bob). "0x6f8ae93..." in the to field represents the address of the smart contract being called, and the data field of the transaction includes the method and parameters for calling the smart contract. After consensus is reached on the transaction in the blockchain, each node in the blockchain can execute the transaction respectively, thereby executing the contract respectively, and update the status database based on the execution of the contract.
如前所述,在一些区块链的应用场景中,有时需要根据世界状态中某些变量的值来执行预设操作。举例来说,在基于区块链的隐私计算过程中,需要收集到足够的数据使用授权才可以启动隐私计算操作对应的工作流合约。为此,在一种方案中,隐私计算对应的工作流合约的数据授权添加功能除了添加授权外,还需要检查基于交易添加授权后是否已经获得了所需的数据访问授权,并在授权满足要求后,主动以工作流发起者身份在本交易的执行过程中去启动工作流合约。这种方案需要将根据授权添加情况自动启动工作流合约的逻辑写入合约体,不够灵活,无法应对合约开发时未预期到的功能需求。且为了扩充合约能力而对合约进行升级还会牵涉到相关各方面的审核。根据另一种方案,区块链支持通过交易查询工作流合约已获得的授权状态,工作流发起者外部定期调用查询接口,在确定工作流合约获得足够授权后,发送交易启动工作流。这种方案需要外部定期通过交易采用轮询方式去查询授权状态,缺乏实时性,也使得计算具有较高的能耗。As mentioned before, in some blockchain application scenarios, it is sometimes necessary to perform preset operations based on the values of certain variables in the world state. For example, in the process of privacy computing based on the blockchain, sufficient data usage authorization needs to be collected before the workflow contract corresponding to the privacy computing operation can be started. To this end, in one solution, in addition to adding authorization, the data authorization adding function of the workflow contract corresponding to privacy computing also needs to check whether the required data access authorization has been obtained after adding authorization based on the transaction, and when the authorization meets the requirements Then, take the initiative as the workflow initiator to start the workflow contract during the execution of this transaction. This solution requires writing the logic of automatically starting the workflow contract according to the authorization addition status into the contract body, which is not flexible enough and cannot cope with unexpected functional requirements during contract development. And upgrading the contract in order to expand the contract capacity will also involve the review of all relevant aspects. According to another solution, the blockchain supports querying the authorization status obtained by the workflow contract through transactions. The workflow initiator regularly calls the query interface externally. After determining that the workflow contract has obtained sufficient authorization, a transaction is sent to start the workflow. This solution requires external polling to query the authorization status periodically through transactions, which lacks real-time performance and also causes high energy consumption in computing.
为此,本说明书的实施例提供了一种基于变量状态自动执行合约的方法,从而实现了及时感知世界状态中变量的状态变化,并基于变量状态的改变自动执行预设操作。To this end, embodiments of this specification provide a method for automatically executing a contract based on the state of variables, thereby realizing timely perception of state changes of variables in the world state and automatically executing preset operations based on changes in variable state.
如图2所示,图2示出了本说明书实施例可以应用于其中的一个应用场景的示意图,本应用场景可以是基于区块链进行隐私计算的场景。本场景中,数据使用授权数量达到一定量之后,可以启动对应的隐私计算。也就是说,用于表示授权数据数量的变量N1的值在改变后会影响隐私计算对应操作的执行,因此,在通过合约C1定义变量N1时,将变量N1的类型声明为目标类型,并将变量N1的信息存储在合约C1的合约状态中。作为示例,可以允许用户查询世界状态中目标类型的变量的状态。As shown in Figure 2, Figure 2 shows a schematic diagram of an application scenario in which the embodiments of this specification can be applied. This application scenario can be a scenario of privacy computing based on the blockchain. In this scenario, after the number of data usage authorizations reaches a certain amount, the corresponding privacy calculation can be started. That is to say, the value of variable N1 used to represent the amount of authorized data will affect the execution of the corresponding operations of privacy calculation after change. Therefore, when defining variable N1 through contract C1, declare the type of variable N1 as the target type, and The information of variable N1 is stored in the contract state of contract C1. As an example, you could allow the user to query the state of a variable of a target type in the world state.
区块链的节点可以接收调用方B发送的用于注册回调项的交易Tx1,交易Tx1可以调用合约C1,交易Tx1可以包括变量N1的变量名、回调合约的回调参数和回调合约的信息(例如,回调合约的合约地址)。本例中,回调合约可以用于判断当前时刻变量N1是否超过预设的数量阈值,当变量N1超过预设数量阈值时,调用用于进行隐私计算的工作流合约进行相关的隐私计算操作。区块链的节点可以执行交易Tx1,在针对变量N1 预先设置的回调列表中添加回调项,其中,回调项可以包括回调合约的信息、调用方B的账户和回调合约的回调参数。作为示例,变量N1对应的回调列表可以存储在合约C1的合约状态中。The node of the blockchain can receive the transaction Tx1 sent by the caller B to register the callback item. The transaction Tx1 can call the contract C1. The transaction Tx1 can include the variable name of the variable N1, the callback parameters of the callback contract and the information of the callback contract (such as , the contract address of the callback contract). In this example, the callback contract can be used to determine whether the variable N1 at the current moment exceeds the preset quantity threshold. When the variable N1 exceeds the preset quantity threshold, the workflow contract used for privacy calculations is called to perform related privacy calculation operations. The node of the blockchain can execute transaction Tx1 and add a callback item to the callback list preset for variable N1. The callback item can include the information of the callback contract, the account of caller B and the callback parameters of the callback contract. As an example, the callback list corresponding to variable N1 can be stored in the contract state of contract C1.
这样,数据所有者A可以向区块链的节点发送用于将授权信息上链的目标交易,该目标交易可以调用合约C1。区块链的节点可以接收和执行数据所有者A发送的目标交易,并根据目标交易的执行结果确定目标类型的变量N1的状态发生改变。此时,区块链的节点可以在合约C1的合约状态中确定是否包含针对变量N1的回调列表,回调列表中的回调项可以包括回调合约的信息和回调参数。如果合约C1的合约状态中包括针对变量N1的回调列表,则基于回调列表中的回调项的回调参数执行回调合约,该回调合约可以判断当前时刻变量N1的值是否超过预设的数量阈值,如果超过,则调用用于进行隐私计算的工作流合约进行相关的隐私计算操作。从而实现了及时感知变量N1的变化,并基于变量N1的世界状态的改变自动调用隐私计算对应的工作流合约,进行隐私计算操作。本方法不需要在隐私计算对应的工作流合约的合约体中规定变量N1的世界状态发生改变后需要执行的动作,而是由调用方B通过注册回调项的方式来进行定制,具有灵活性。此外,本方法不需要外部定期通过交易采用轮询方式去查询变量N1的值,节约了能耗。In this way, data owner A can send a target transaction for uploading authorization information to the node of the blockchain, and the target transaction can call contract C1. The nodes of the blockchain can receive and execute the target transaction sent by the data owner A, and determine the change in the state of the target type variable N1 based on the execution result of the target transaction. At this time, the node of the blockchain can determine whether the callback list for variable N1 is included in the contract status of contract C1. The callback items in the callback list can include callback contract information and callback parameters. If the contract status of contract C1 includes a callback list for variable N1, the callback contract is executed based on the callback parameters of the callback items in the callback list. The callback contract can determine whether the value of variable N1 at the current moment exceeds the preset quantity threshold. If If it exceeds, the workflow contract used for privacy calculation will be called to perform related privacy calculation operations. This achieves timely perception of changes in variable N1, and automatically calls the workflow contract corresponding to privacy computing based on changes in the world state of variable N1 to perform privacy computing operations. This method does not need to specify the actions that need to be performed after the world state of variable N1 changes in the contract body of the workflow contract corresponding to the privacy calculation. Instead, the caller B can customize it by registering a callback item, which is flexible. In addition, this method does not require external polling to query the value of variable N1 periodically through transactions, thus saving energy consumption.
继续参见图3,图3示出了根据一个实施例的基于变量状态自动执行合约的方法的流程示意图。可以理解,该方法可以通过区块链的节点来执行,区块链的节点可以由任何具有计算、处理能力的装置、设备、设备集群等来实现。Continuing to refer to FIG. 3 , FIG. 3 shows a schematic flowchart of a method for automatically executing a contract based on variable status according to one embodiment. It can be understood that this method can be performed by nodes of the blockchain, and the nodes of the blockchain can be implemented by any device, equipment, equipment cluster, etc. with computing and processing capabilities.
如图3所示,该基于变量状态自动执行合约的方法,可以包括以下步骤:As shown in Figure 3, the method of automatically executing a contract based on variable status can include the following steps:
步骤301,根据目标交易的执行结果确定目标类型的第一变量的状态发生变化。Step 301: Determine a change in the state of the first variable of the target type based on the execution result of the target transaction.
在本实施例中,区块链的节点可以接收和执行用户发送的目标交易,执行完该目标交易后,区块链的节点可以根据该目标交易的执行结果确定目标类型的第一变量的状态发生改变。也就是说,目标交易的执行结果会改变世界状态中目标类型的第一变量的状态。这里,目标类型的第一变量可以是预先通过第一合约定义的,在通过第一合约定义第一变量的时候,可以将第一变量的类型声明为目标类型,并将第一变量的信息(例如,变量值、变量名、属性等等)存储在第一合约的合约状态中。上述目标交易可以调用第一合约,以改变第一合约的合约状态中记录的第一变量的变量值。In this embodiment, the node of the blockchain can receive and execute the target transaction sent by the user. After executing the target transaction, the node of the blockchain can determine the state of the first variable of the target type based on the execution result of the target transaction. changes happened. That is to say, the execution result of the target transaction will change the state of the first variable of the target type in the world state. Here, the first variable of the target type can be defined in advance through the first contract. When defining the first variable through the first contract, the type of the first variable can be declared as the target type, and the information of the first variable ( For example, variable values, variable names, attributes, etc.) are stored in the contract state of the first contract. The above target transaction can call the first contract to change the variable value of the first variable recorded in the contract state of the first contract.
为了在第一变量的状态发生变化后,自动执行预设操作,用户可以在针对第一变量预设的回调列表中注册针对第一变量的回调项,其中,针对第一变量的回调列表可以存储在第一合约的合约状态中。这里,用户可以是调用回调合约的调用方。这样,区块链的节点可以基于当前世界状态中第一变量的状态自动执行该回调合约,举例来说,当确定某交易执行后第一合约的合约状态中第一变量的状态发生改变时,可以调用用户预先针对第一变量注册的回调列表中的回调项。In order to automatically perform the preset operation after the state of the first variable changes, the user can register a callback item for the first variable in the callback list preset for the first variable, where the callback list for the first variable can be stored In the contract state of the first contract. Here, the user can be the caller who calls the callback contract. In this way, the node of the blockchain can automatically execute the callback contract based on the state of the first variable in the current world state. For example, when it is determined that the state of the first variable in the contract state of the first contract changes after a transaction is executed, The callback items in the callback list pre-registered by the user for the first variable can be called.
在一些可选的实现方式中,如图4所示,图4示出了针对第一变量注册回调项的一 个例子的流程示意图。图4所示的例子中,可以通过以下方式针对第一变量注册回调项:In some optional implementations, as shown in Figure 4, Figure 4 shows a schematic flow chart of an example of registering a callback item for the first variable. In the example shown in Figure 4, the callback item can be registered for the first variable in the following way:
S401,回调合约的调用方可以向区块链发送用于注册回调项的第一交易。S401, the caller of the callback contract can send the first transaction for registering the callback item to the blockchain.
在本实现方式中,该第一交易可以包括第一变量的变量名、回调合约的信息和回调合约的回调参数。这里,回调合约的信息可以包括回调合约的代码、回调合约的地址等等。回调参数可以是指调用回调合约时使用的参数。实践中,调用方可以根据实际的业务需要设置回调合约的回调参数,以及在回调合约中定义对应的业务逻辑,即定义针对第一变量的状态变化要对应执行的操作。例如,在隐私计算的业务场景中,假设第一变量为隐私计算中的数据访问授权量,回调合约可以用于判断当前时刻数据访问授权量是否超过预设的数量阈值,当数据访问授权量超过该数量阈值时,调用预设的工作流合约,该工作流合约可以用于进行隐私计算的相关操作。具体的,可以在回调合约中定义隐私计算对应的工作流合约的合约地址,以及调用隐私计算的对应工作流合约的业务逻辑,比如,业务逻辑可以是当授权数据数量超过预设值时调用隐私计算的对应的工作流合约。又例如,在一个根据账号的账号余额发送邮件的业务场景中,可以在回调合约中定义发送邮件的业务逻辑,比如,业务逻辑可以是当账户余额少于预设值时,向账户对应的邮箱自动发送预设内容邮件。In this implementation, the first transaction may include the variable name of the first variable, information about the callback contract, and callback parameters of the callback contract. Here, the information of the callback contract can include the code of the callback contract, the address of the callback contract, etc. The callback parameters can refer to the parameters used when calling the callback contract. In practice, the caller can set the callback parameters of the callback contract according to actual business needs, and define the corresponding business logic in the callback contract, that is, define the operations to be performed corresponding to the state change of the first variable. For example, in the business scenario of privacy computing, assuming that the first variable is the amount of data access authorization in privacy computing, the callback contract can be used to determine whether the amount of data access authorization at the current moment exceeds the preset quantity threshold. When the amount of data access authorization exceeds When this quantity threshold is exceeded, the preset workflow contract is called, which can be used to perform privacy calculation-related operations. Specifically, the contract address of the workflow contract corresponding to privacy calculation can be defined in the callback contract, as well as the business logic of the corresponding workflow contract that calls privacy calculation. For example, the business logic can be to call privacy when the amount of authorized data exceeds the preset value. The calculated corresponding workflow contract. For another example, in a business scenario where emails are sent based on the account balance of an account, the business logic for sending emails can be defined in the callback contract. For example, the business logic can be that when the account balance is less than the preset value, a mailbox corresponding to the account will be sent. Automatically send emails with preset content.
区块链的节点可以接收调用方发送的用于注册回调项的第一交易,该第一交易可以调用第一合约。The node of the blockchain can receive the first transaction sent by the caller for registering the callback item, and the first transaction can call the first contract.
S403,区块链的节点可以执行第一交易,在针对第一变量预先设置的回调列表中添加回调项。S403: The node of the blockchain can execute the first transaction and add a callback item to the callback list preset for the first variable.
在本实现方式中,区块链的节点可以执行第一交易,调用第一合约,在针对第一变量预先设置的回调列表中添加一个回调项,该回调项可以包括回调合约的信息、调用方的账户、回调合约的回调参数等等。其中,针对第一变量的回调列表可以存储在第一合约的合约状态中。可以理解,当有调用方针对第一变量注册回调项时,才会针对第一变量设置回调列表。如果没有调用方针对第一变量注册回调项,或者针对第一变量注册的回调项在注册后又被注销,则可以不针对第一变量设置回调列表。通过本实现方式,调用方可以根据实际的业务需要针对第一变量设置回调项,并在回调项包括的回调合约中定义针对第一变量的状态变化要执行的操作。本方式通过注册回调项来定制当第一变量的状态变化时要执行的操作,而不需要修改与业务相关的其他已有合约,因此,具有灵活性。In this implementation, the node of the blockchain can execute the first transaction, call the first contract, and add a callback item to the callback list preset for the first variable. The callback item can include the information of the callback contract, the caller Account, callback parameters of the callback contract, etc. Wherein, the callback list for the first variable can be stored in the contract state of the first contract. It can be understood that when a caller registers a callback item for the first variable, the callback list will be set for the first variable. If no callback item is registered by the caller for the first variable, or the callback item registered for the first variable is then unregistered, the callback list does not need to be set for the first variable. Through this implementation, the caller can set a callback item for the first variable according to actual business needs, and define the operations to be performed for the state change of the first variable in the callback contract included in the callback item. This method customizes the operation to be performed when the state of the first variable changes by registering a callback item without modifying other existing contracts related to the business, so it is flexible.
在一些可选的实现方式中,如图5所示,图5示出了针对第一变量注销回调项的一个例子的流程示意图。图5所示的例子中,调用方还可以通过以下方式注销针对第一变量注册的回调项:In some optional implementations, as shown in Figure 5, Figure 5 shows a schematic flow chart of an example of a first variable logout callback item. In the example shown in Figure 5, the caller can also unregister the callback item registered for the first variable in the following way:
S501,回调合约的调用方可以向区块链发送用于注销回调项的第二交易。S501, the caller of the callback contract can send a second transaction for canceling the callback item to the blockchain.
在本实现方式中,该第二交易可以包括调用方的账户和第一变量的变量名。In this implementation, the second transaction may include the caller's account and the variable name of the first variable.
区块链的节点可以接收调用方发送的用于注销回调项的第二交易,该第二交易可 以调用第一合约。The node of the blockchain can receive the second transaction sent by the caller to cancel the callback item, and the second transaction can call the first contract.
S503,区块链的节点可以执行第二交易,在针对第一变量对应的回调列表中删除包含调用方的账户的回调项。S503: The node of the blockchain can execute the second transaction and delete the callback item containing the caller's account from the callback list corresponding to the first variable.
在本实现方式中,区块链的节点可以执行第二交易,以调用第一合约,在针对第一变量对应的回调列表中删除包含调用方的账户的回调项。具体的,区块链的节点可以根据第二交易中包括的第一变量的变量名,在第一合约的合约状态中查找针对第一变量的回调列表,然后从查找到的回调列表中删除包含调用方的账户的回调项。通过本实现方式,调用方可以根据实际的业务需要删除之前针对第一变量设置的回调项,从而实现回调项的灵活设置。In this implementation, the node of the blockchain can execute the second transaction to call the first contract, and delete the callback item containing the caller's account from the callback list corresponding to the first variable. Specifically, the node of the blockchain can search the callback list for the first variable in the contract state of the first contract based on the variable name of the first variable included in the second transaction, and then delete the callback list containing The callback item for the caller's account. Through this implementation method, the caller can delete the callback items previously set for the first variable according to actual business needs, thereby realizing flexible setting of callback items.
步骤302,在第一合约的合约状态中确定是否包含针对第一变量的回调列表。Step 302: Determine whether the contract state of the first contract contains a callback list for the first variable.
在本实施例中,在根据目标交易的执行结果确定目标类型的第一变量的状态发生改变后,区块链的节点可以在第一合约的合约状态中确定是否包含针对第一变量的回调列表。其中,回调列表中可以包括回调项,回调项可以包括回调合约的信息、回调参数等等。In this embodiment, after determining that the state of the first variable of the target type has changed based on the execution result of the target transaction, the node of the blockchain can determine whether the callback list for the first variable is included in the contract state of the first contract. . Among them, the callback list can include callback items, and the callback items can include callback contract information, callback parameters, etc.
步骤303,响应于确定包含针对第一变量的回调列表,基于回调列表中回调项的回调参数,执行回调合约。Step 303: In response to determining that the callback list for the first variable is included, execute the callback contract based on the callback parameters of the callback items in the callback list.
在本实施例中,如果区块链的节点确定在第一合约的合约状态中包含针对第一变量的回调列表,则区块链的节点可以基于该回调列表中的回调项的回调参数,执行回调合约。实践中,针对第一变量的回调列表中可以包括一条或多条回调项,例如,可以包括一个调用方注册的一条回调项,还可以包括多个调用方注册的多个回调项。In this embodiment, if the node of the blockchain determines that the contract state of the first contract contains a callback list for the first variable, the node of the blockchain can execute based on the callback parameters of the callback items in the callback list. Callback contract. In practice, the callback list for the first variable may include one or more callback items. For example, it may include one callback item registered by one caller, or may include multiple callback items registered by multiple callers.
在一些可选的实现方式中,步骤303中的基于回调列表中回调项的回调参数,执行回调合约,可以具体如下进行:在目标交易执行完成后,基于回调列表中回调项的回调参数,执行回调项包括的回调合约的信息所对应的回调合约。通过本实现方式,可以在目标交易执行完成后,立即执行第一变量的回调列表中包含的回调项对应的回调合约。In some optional implementations, executing the callback contract based on the callback parameters of the callback item in the callback list in step 303 can be performed as follows: after the target transaction is executed, based on the callback parameters of the callback item in the callback list, execute The callback contract corresponding to the callback contract information included in the callback item. Through this implementation method, the callback contract corresponding to the callback item contained in the callback list of the first variable can be executed immediately after the execution of the target transaction is completed.
在另一些可选的实现方式中,上述目标交易可以是目标区块中的交易,该目标区块可以是达成共识的区块,该目标区块内可以包括一个或者多个交易。以及步骤303中的基于回调列表中回调项的回调参数,执行回调合约,还可以具体如下进行:In other optional implementations, the above-mentioned target transaction may be a transaction in a target block, the target block may be a consensus block, and the target block may include one or more transactions. And in step 303, based on the callback parameters of the callback items in the callback list, the callback contract can be executed as follows:
首先,区块链的节点可以判断当前时刻目标区块中包含的多个交易是否执行完成。First, the nodes of the blockchain can determine whether the multiple transactions contained in the target block at the current moment have been completed.
其次,响应于确定当前时刻目标区块中包含的交易没有执行完成,可以将第一变量的变量名添加到预设的待调用列表中。Secondly, in response to determining that the transaction contained in the target block at the current moment has not been completed, the variable name of the first variable can be added to the preset to-be-called list.
然后,响应于确定当前时刻目标区块中包含的交易执行完成,将第一变量的变量名添加到待调用列表之后,基于待调用列表中包含的变量名,从对应变量的回调列表的回调项中确定对应的回调合约和回调参数,并通过确定的回调参数调用对应的回调合约。Then, in response to determining that the execution of the transaction contained in the target block at the current moment is completed, after adding the variable name of the first variable to the to-be-called list, based on the variable name contained in the to-be-called list, the callback item of the callback list of the corresponding variable is Determine the corresponding callback contract and callback parameters, and call the corresponding callback contract through the determined callback parameters.
在本实现方式中,如果目标交易所在的目标区块中包括多个交易,则区块链的节点可以判断当前时刻目标区块中的多个交易是否都执行完成。如果目标区块中的多个交易没有都执行完成,则可以将第一变量的变量名添加到预设的待调用列表中,实践中,待调用列表中可以包括一个或者多个目标类型的变量的变量名。如果目标区块中的多个交易都执行完成,则可以在将第一变量的变量名添加到待调用列表之后,根据待调用列表中包含的至少一个变量的变量名执行对应的回调合约。以第一变量为例,区块链的节点可以根据第一变量的变量名从第一合约的合约状态中查询第一变量的回调列表,而后从第一变量的回调列表的回调项中确定对应的回调合约和回调参数,并通过确定的回调参数调用对应的回调合约。通过本实现方式,可以在目标区块中的多个交易都执行完之后,再执行回调合约,从而增加了回调合约执行的灵活性。In this implementation, if the target block where the target transaction is located includes multiple transactions, the node of the blockchain can determine whether the multiple transactions in the target block at the current moment have been completed. If multiple transactions in the target block are not all executed, the variable name of the first variable can be added to the preset to-be-called list. In practice, the to-be-called list can include one or more variables of the target type. variable name. If multiple transactions in the target block are executed, then after adding the variable name of the first variable to the to-be-called list, the corresponding callback contract can be executed based on the variable name of at least one variable included in the to-be-called list. Taking the first variable as an example, the node of the blockchain can query the callback list of the first variable from the contract status of the first contract based on the variable name of the first variable, and then determine the corresponding callback item from the callback list of the first variable. callback contract and callback parameters, and call the corresponding callback contract through the determined callback parameters. Through this implementation method, the callback contract can be executed after multiple transactions in the target block have been executed, thereby increasing the flexibility of callback contract execution.
可选的,区块链的节点还可以对待调用列表中包含的变量名对应的回调项进行排序。举例来说,区块链的节点首先可以获取待调用列表中变量名对应的变量的回调列表中的回调项,然后可以采用各种方式对获取的调用项进行排序,例如,随机排序。对待调用列表中包含变量名对应的回调项进行排序后,区块链的节点可以根据排序结果顺序执行各个回调项,具体的,对于某一个回调项,可以基于该回调项的回调参数调用对应的回调合约。Optionally, the nodes of the blockchain can also sort the callback items corresponding to the variable names contained in the to-be-called list. For example, the node of the blockchain can first obtain the callback items in the callback list of the variable corresponding to the variable name in the to-be-called list, and then sort the obtained call items in various ways, such as random ordering. After sorting the callback items corresponding to the variable names in the to-be-called list, the nodes of the blockchain can execute each callback item in the order according to the sorting result. Specifically, for a certain callback item, the corresponding callback item can be called based on the callback parameter of the callback item. Callback contract.
作为一个示例,目标类型的变量的回调列表中的回调项除了包括回调合约的信息、回调参数等之外,还可以包括回调优先级。作为示例,回调优先级可以是调用方在注册回调项的时候设置的。举例来说,调用方可以在注册回调项的时候,设置愿意为执行回调合约所付的费用,所付费用越高优先级越高。也就是说,区块链的节点可以根据付费高低确定回调项的优先级。基于此,上述对待调用列表中包含的变量名对应的回调项进行排序,可以具体如下进行:根据待调用列表中各变量名对应的回调项的回调优先级,对待调用列表中包含的各变量名对应的回调项进行排序。例如,可以按回调优先级由高到低的顺序进行排序。通过本实现方式中,可以基于回调项的回调优先级,来控制待调用列表中变量名对应的回调项的执行顺序。As an example, the callback items in the callback list of the target type variable can also include the callback priority in addition to the callback contract information, callback parameters, etc. As an example, the callback priority can be set by the caller when registering the callback item. For example, the caller can set the fee that it is willing to pay for executing the callback contract when registering the callback item. The higher the fee, the higher the priority. In other words, the nodes of the blockchain can determine the priority of callback items based on the level of payment. Based on this, the above-mentioned sorting of the callback items corresponding to the variable names contained in the to-be-called list can be performed as follows: According to the callback priority of the callback items corresponding to each variable name in the to-be-called list, each variable name included in the to-be-called list is sorted The corresponding callback items are sorted. For example, you can sort callbacks from high to low priority. In this implementation, the execution order of the callback items corresponding to the variable names in the to-be-called list can be controlled based on the callback priority of the callback item.
作为另一示例,上述对待调用列表中包含的变量名对应的回调项进行排序,还可以具体如下进行:As another example, the above-mentioned sorting of callback items corresponding to variable names contained in the to-be-called list can also be performed as follows:
首先,可以根据待调用列表中各变量名对应的回调项的回调合约、回调方账户,以及目标交易所在的目标区块的区块号,计算哈希。可以理解,实践中,还可以根据实际需要确定用于计算哈希的信息,不限于使用回调合约、回调方账户和区块号。例如,可以使用回调合约和回调方账户计算哈希。又例如,还可以使用回调合约、回调方账户和回调项的注册时间等计算哈希等等。First, the hash can be calculated based on the callback contract of the callback item corresponding to each variable name in the to-be-called list, the callback party account, and the block number of the target block where the target transaction is located. It can be understood that in practice, the information used to calculate the hash can also be determined according to actual needs, and is not limited to the use of callback contracts, callback party accounts and block numbers. For example, the hash can be calculated using the callback contract and the callback party account. For another example, you can also use the callback contract, the callback party account and the registration time of the callback item to calculate the hash and so on.
然后,根据哈希的计算结果,对待调用列表中包含的变量名对应的回调项进行排序。例如,可以按哈希计算结果由大到小或者由小到大的顺序进行排序。通过本实现方式中,可以基于哈希计算,确定待调用列表中变量名对应的回调项的执行顺序。Then, based on the hash calculation results, the callback items corresponding to the variable names contained in the to-be-called list are sorted. For example, you can sort the hash calculation results from large to small or from small to large. In this implementation, the execution order of the callback items corresponding to the variable names in the to-be-called list can be determined based on hash calculation.
回顾以上过程,在本说明书的实施例中,在使用合约定义变量时,可以将状态改变后会影响预设操作执行的第一变量的类型声明为目标类型,其中,目标类型的第一变量可以通过第一合约定义。区块链的节点首先可以根据目标交易的执行结果确定目标类型的第一变量的状态发生改变,之后,在第一合约的合约状态中确定是否包含针对第一变量的回调列表,回调列表中的回调项包括回调合约的信息和回调参数。如果确定第一合约的合约状态中包含针对第一变量的回调列表,基于回调列表中回调项的回调参数执行回调合约,基于回调合约可以执行预设操作,从而实现了及时感知世界状态中目标类型的变量的状态变化,并基于目标类型的变量的状态的改变自动执行预设操作。Reviewing the above process, in the embodiment of this specification, when using a contract to define variables, the type of the first variable that will affect the execution of the preset operation after the state changes can be declared as the target type, where the first variable of the target type can Defined by the first contract. The node of the blockchain can first determine that the state of the first variable of the target type has changed based on the execution result of the target transaction, and then determine whether a callback list for the first variable is included in the contract state of the first contract. Callback items include callback contract information and callback parameters. If it is determined that the contract state of the first contract contains a callback list for the first variable, the callback contract is executed based on the callback parameters of the callback item in the callback list, and the preset operation can be performed based on the callback contract, thus achieving timely perception of the target type in the world state. The state change of the variable, and automatically perform the preset operation based on the change of the state of the variable of the target type.
根据另一方面的实施例,提供了一种基于变量状态自动执行合约的装置。上述基于变量状态自动执行合约的装置可以部署在区块链的节点,区块链的节点可以由任何具有计算、处理能力的装置、设备、设备集群等来实现。According to an embodiment of another aspect, an apparatus for automatically executing a contract based on the state of a variable is provided. The above-mentioned device for automatically executing contracts based on variable states can be deployed on the nodes of the blockchain. The nodes of the blockchain can be implemented by any device, equipment, equipment cluster, etc. with computing and processing capabilities.
图6示出了根据一个实施例的基于变量状态自动执行合约的装置的示意性框图。如图6所示,该基于变量状态自动执行合约的装置600包括:第一确定单元601,配置为根据目标交易的执行结果确定目标类型的第一变量的状态发生改变,其中,上述目标交易调用第一合约;第二确定单元602,配置为在上述第一合约的合约状态中确定是否包含针对上述第一变量的回调列表,其中,上述回调列表中的回调项包括回调合约的信息和回调参数;执行单元603,配置为响应于确定包含针对上述第一变量的回调列表,基于上述回调列表中回调项的回调参数,执行回调合约。Figure 6 shows a schematic block diagram of a device for automatically executing a contract based on variable states according to one embodiment. As shown in Figure 6, the device 600 for automatically executing a contract based on variable status includes: a first determination unit 601 configured to determine that the status of the first variable of the target type has changed based on the execution result of the target transaction, wherein the above target transaction calls The first contract; the second determination unit 602 is configured to determine whether the callback list for the above-mentioned first variable is included in the contract state of the above-mentioned first contract, wherein the callback items in the above-mentioned callback list include callback contract information and callback parameters. ; The execution unit 603 is configured to execute the callback contract based on the callback parameters of the callback items in the above-mentioned callback list in response to determining that the callback list contains the above-mentioned first variable.
在本实施例的一些可选的实现方式中,上述装置600还包括:第一接收单元(图中未示出),配置为接收调用方发送的用于注册回调项的第一交易,上述第一交易调用上述第一合约,其中,上述第一交易包括上述第一变量的变量名、回调合约的回调参数和回调合约的信息;添加单元(图中未示出),配置为执行上述第一交易,在针对上述第一变量预先设置的回调列表中添加回调项,其中,上述回调项包括上述回调合约的信息、上述调用方的账户和上述回调参数。In some optional implementations of this embodiment, the above-mentioned device 600 further includes: a first receiving unit (not shown in the figure) configured to receive the first transaction sent by the caller for registering a callback item, the above-mentioned first transaction A transaction calls the above-mentioned first contract, wherein the above-mentioned first transaction includes the variable name of the above-mentioned first variable, the callback parameters of the callback contract, and the information of the callback contract; an adding unit (not shown in the figure) is configured to execute the above-mentioned first contract. Transaction, add a callback item to the callback list preset for the above-mentioned first variable, where the above-mentioned callback item includes the above-mentioned callback contract information, the above-mentioned caller's account and the above-mentioned callback parameters.
在本实施例的一些可选的实现方式中,上述装置600还包括:第二接收单元(图中未示出),配置为接收上述调用方发送的用于注销回调项的第二交易,上述第二交易调用上述第一合约,其中,上述第二交易包括上述第一变量的变量名;删除单元(图中未示出),配置为执行上述第二交易,在针对上述第一变量对应的回调列表中删除包含上述调用方的账户的回调项。In some optional implementations of this embodiment, the above-mentioned device 600 further includes: a second receiving unit (not shown in the figure) configured to receive the second transaction sent by the above-mentioned caller for canceling the callback item, the above-mentioned The second transaction calls the above-mentioned first contract, wherein the above-mentioned second transaction includes the variable name of the above-mentioned first variable; the deletion unit (not shown in the figure) is configured to execute the above-mentioned second transaction. The callback items containing the above caller's account are deleted from the callback list.
在本实施例的一些可选的实现方式中,上述执行单元603进一步配置为:在上述目标交易执行完成后,基于上述回调列表中回调项的回调参数,执行回调合约。In some optional implementations of this embodiment, the above-mentioned execution unit 603 is further configured to: after the execution of the above-mentioned target transaction is completed, execute the callback contract based on the callback parameters of the callback item in the above-mentioned callback list.
在本实施例的一些可选的实现方式中,上述目标交易为目标区块中的交易,以及上述执行单元603包括:变量名添加模块(图中未示出),配置为响应于确定当前时刻上述目标区块中包含的交易没有执行完成,将上述第一变量的变量名添加到预设的 待调用列表中;合约调用模块(图中未示出),配置为响应于确定当前时刻上述目标区块中包含的交易执行完成,将上述第一变量的变量名添加到上述待调用列表之后,基于上述待调用列表中包含的变量名,从对应变量的回调列表的回调项中确定对应的回调合约和回调参数,并通过确定的回调参数调用对应的回调合约。In some optional implementations of this embodiment, the above-mentioned target transaction is a transaction in the target block, and the above-mentioned execution unit 603 includes: a variable name adding module (not shown in the figure) configured to respond to determining the current moment If the transaction contained in the above-mentioned target block has not been completed, the variable name of the above-mentioned first variable is added to the preset to-be-called list; the contract calling module (not shown in the figure) is configured to respond to determining the above-mentioned target at the current moment. After the execution of the transaction included in the block is completed and the variable name of the above-mentioned first variable is added to the above-mentioned to-be-called list, the corresponding callback is determined from the callback items of the callback list of the corresponding variable based on the variable name contained in the above-mentioned to-be-called list. contract and callback parameters, and call the corresponding callback contract through the determined callback parameters.
在本实施例的一些可选的实现方式中,上述装置600还包括:排序模块(图中未示出),配置为对上述待调用列表中包含的变量名对应的回调项进行排序。In some optional implementations of this embodiment, the above-mentioned device 600 further includes: a sorting module (not shown in the figure) configured to sort the callback items corresponding to the variable names included in the above-mentioned to-be-called list.
在本实施例的一些可选的实现方式中,回调项还包括回调优先级,以及上述排序模块进一步配置为:根据待调用列表中各变量名对应的回调项的回调优先级,对上述待调用列表中包含的各变量名对应的回调项进行排序。In some optional implementations of this embodiment, the callback item also includes a callback priority, and the above-mentioned sorting module is further configured to: according to the callback priority of the callback item corresponding to each variable name in the to-be-called list, the above-mentioned to-be-called The callback items corresponding to each variable name contained in the list are sorted.
在本实施例的一些可选的实现方式中,上述排序模块进一步配置为:根据待调用列表中各变量名对应的回调项的回调合约、回调方账户,以及目标交易所在的目标区块的区块号,计算哈希;根据哈希的计算结果,对上述待调用列表中包含的变量名对应的回调项进行排序。In some optional implementations of this embodiment, the above-mentioned sorting module is further configured to: based on the callback contract of the callback item corresponding to each variable name in the to-be-called list, the callback party account, and the target block in which the target transaction is located. Block number, calculate the hash; according to the hash calculation result, sort the callback items corresponding to the variable names contained in the above to-be-called list.
在本实施例的一些可选的实现方式中,上述第一变量为隐私计算中的数据访问授权量,以及上述回调合约用于判断当前时刻数据访问授权量是否超过预设的数量阈值,当数据访问授权量超过上述数量阈值时,调用预设的工作流合约,其中,上述工作流合约用于进行隐私计算的相关操作。In some optional implementations of this embodiment, the above-mentioned first variable is the data access authorization amount in privacy calculation, and the above-mentioned callback contract is used to determine whether the data access authorization amount at the current moment exceeds a preset quantity threshold. When the data When the amount of access authorization exceeds the above quantity threshold, the preset workflow contract is called, where the above workflow contract is used to perform operations related to privacy calculations.
根据另一方面的实施例,还提供一种计算机可读存储介质,其上存储有计算机程序,当上述计算机程序在计算机中执行时,令计算机执行图3所描述的方法。According to another aspect of the embodiment, a computer-readable storage medium is also provided, on which a computer program is stored. When the above-mentioned computer program is executed in a computer, the computer is caused to execute the method described in FIG. 3 .
根据再一方面的实施例,还提供一种区块链的节点,包括存储器和处理器,其特征在于,上述存储器中存储有可执行代码,上述处理器执行上述可执行代码时,实现图3所描述的方法。According to yet another aspect of the embodiment, a blockchain node is also provided, including a memory and a processor, characterized in that executable code is stored in the memory, and when the processor executes the executable code, Figure 3 is implemented. method described.
在20世纪90年代,对于一个技术的改进可以很明显地区分是硬件上的改进(例如,对二极管、晶体管、开关等电路结构的改进)还是软件上的改进(对于方法流程的改进)。然而,随着技术的发展,当今的很多方法流程的改进已经可以视为硬件电路结构的直接改进。设计人员几乎都通过将改进的方法流程编程到硬件电路中来得到相应的硬件电路结构。因此,不能说一个方法流程的改进就不能用硬件实体模块来实现。例如,可编程逻辑器件(Programmable Logic Device,PLD)(例如现场可编程门阵列(Field Programmable Gate Array,FPGA))就是这样一种集成电路,其逻辑功能由用户对器件编程来确定。由设计人员自行编程来把一个数字***“集成”在一片PLD上,而不需要请芯片制造厂商来设计和制作专用的集成电路芯片。而且,如今,取代手工地制作集成电路芯片,这种编程也多半改用“逻辑编译器(logic compiler)”软件来实现,它与程序开发撰写时所用的软件编译器相类似,而要编译之前的原始代码也得用特定的编程语言来撰写,此称之为硬件描述语言(Hardware Description Language,HDL),而HDL也并非仅有一种,而是有许多种,如ABEL(Advanced Boolean Expression Language)、AHDL(Altera Hardware Description Language)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(Ruby Hardware Description Language)等,目前最普遍使用的是VHDL(Very-High-Speed Integrated Circuit Hardware Description Language)与Verilog。本领域技术人员也应该清楚,只需要将方法流程用上述几种硬件描述语言稍作逻辑编程并编程到集成电路中,就可以很容易得到实现该逻辑方法流程的硬件电路。In the 1990s, improvements in a technology could be clearly distinguished as hardware improvements (for example, improvements in circuit structures such as diodes, transistors, switches, etc.) or software improvements (improvements in method processes). However, with the development of technology, many improvements in today's method processes can be regarded as direct improvements in hardware circuit structures. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement of a method flow cannot be implemented using hardware entity modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic functions are determined by the user programming the device. Designers can program themselves to "integrate" a digital system on a PLD, instead of asking chip manufacturers to design and produce dedicated integrated circuit chips. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented using "logic compiler" software, which is similar to the software compiler used in program development and writing, and before compilation The original code must also be written in a specific programming language, which is called Hardware Description Language (HDL). There is not only one type of HDL, but many types, such as ABEL (Advanced Boolean Expression Language) , AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc., are currently the most commonly used The two are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that by simply logically programming the method flow using the above-mentioned hardware description languages and programming it into the integrated circuit, the hardware circuit that implements the logical method flow can be easily obtained.
控制器可以按任何适当的方式实现,例如,控制器可以采取例如微处理器或处理器以及存储可由该(微)处理器执行的计算机可读程序代码(例如软件或固件)的计算机可读介质、逻辑门、开关、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程逻辑控制器和嵌入微控制器的形式,控制器的例子包括但不限于以下微控制器:ARC 625D、Atmel AT91SAM、Microchip PIC18F26K20以及Silicone Labs C8051F320,存储器控制器还可以被实现为存储器的控制逻辑的一部分。本领域技术人员也知道,除了以纯计算机可读程序代码方式实现控制器以外,完全可以通过将方法步骤进行逻辑编程来使得控制器以逻辑门、开关、专用集成电路、可编程逻辑控制器和嵌入微控制器等的形式来实现相同功能。因此这种控制器可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置也可以视为硬件部件内的结构。或者甚至,可以将用于实现各种功能的装置视为既可以是实现方法的软件模块又可以是硬件部件内的结构。The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code (eg, software or firmware) executable by the (micro)processor. , logic gates, switches, Application Specific Integrated Circuit (ASIC), programmable logic controllers and embedded microcontrollers. Examples of controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, For Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the memory's control logic. Those skilled in the art also know that in addition to implementing the controller in the form of pure computer-readable program code, the controller can be completely programmed with logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded logic by logically programming the method steps. Microcontroller, etc. to achieve the same function. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the means for implementing various functions can be considered as structures within hardware components as well as software modules implementing the methods.
上述实施例阐明的***、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为服务器***。当然,本申请不排除随着未来计算机技术的发展,实现上述实施例功能的计算机例如可以为个人计算机、膝上型计算机、车载人机交互设备、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a server system. Of course, this application does not rule out that with the development of computer technology in the future, the computer that implements the functions of the above embodiments may be, for example, a personal computer, a laptop computer, a vehicle-mounted human-computer interaction device, a cellular phone, a camera phone, a smart phone, or a personal digital assistant. , media player, navigation device, email device, game console, tablet, wearable device, or a combination of any of these devices.
虽然本说明书一个或多个实施例提供了如实施例或流程图所述的方法操作步骤,但基于常规或者无创造性的手段可以包括更多或者更少的操作步骤。实施例中列举的步骤顺序仅仅为众多步骤执行顺序中的一种方式,不代表唯一的执行顺序。在实际中的装置或终端产品执行时,可以按照实施例或者附图所示的方法顺序执行或者并行执行(例如并行处理器或者多线程处理的环境,甚至为分布式数据处理环境)。术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、产品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、产品或者设备所固有的要素。在没有更多限制的情况下,并不排除在包括所述要素的过程、方法、产品或者设备中还存在另外的相同或等同要素。例如若使用到第一,第二等词语用来表示名称,而并不表示任何 特定的顺序。Although one or more embodiments of this specification provide method operation steps as described in the embodiments or flow charts, more or fewer operation steps may be included based on conventional or non-inventive means. The sequence of steps listed in the embodiment is only one way of executing the sequence of many steps, and does not represent the only execution sequence. When the actual device or terminal product is executed, it may be executed sequentially or in parallel according to the methods shown in the embodiments or figures (for example, a parallel processor or a multi-thread processing environment, or even a distributed data processing environment). The terms "comprises," "comprises" or any other variation thereof are intended to cover a non-exclusive inclusion such that a process, method, product or apparatus including a list of elements includes not only those elements but also others not expressly listed elements, or also elements inherent to the process, method, product or equipment. Without further limitation, it does not exclude the presence of additional identical or equivalent elements in a process, method, product or apparatus including the stated elements. For example, if words such as first and second are used to express names, they do not indicate any specific order.
为了描述的方便,描述以上装置时以功能分为各种模块分别描述。当然,在实施本说明书一个或多个时可以把各模块的功能在同一个或多个软件和/或硬件中实现,也可以将实现同一功能的模块由多个子模块或子单元的组合实现等。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个***,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。For the convenience of description, when describing the above device, the functions are divided into various modules and described separately. Of course, when implementing one or more of this specification, the functions of each module can be implemented in the same or multiple software and/or hardware, or the modules that implement the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. . The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated. to another system, or some features can be ignored, or not implemented. On the other hand, the coupling or direct coupling or communication connection between each other shown or discussed may be through some interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
本发明是参照根据本发明实施例的方法、装置(***)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。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 will be understood that each process and/or block in the flowchart illustrations and/or block diagrams, and combinations of processes and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine, such that the instructions executed by the processor of the computer or other programmable data processing device produce a use A device for realizing the functions specified in one process or multiple processes of the flowchart and/or one block or multiple blocks of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory that causes a computer or other programmable data processing apparatus to operate in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction means, the instructions The device implements the functions specified in a process or processes of the flowchart and/or a block or blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions may also be loaded onto a computer or other programmable data processing device, causing a series of operating steps to be performed on the computer or other programmable device to produce computer-implemented processing, thereby executing on the computer or other programmable device. Instructions provide steps for implementing the functions specified in a process or processes of a flowchart diagram and/or a block or blocks of a block diagram.
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device 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, random access memory (RAM) and/or non-volatile memory in the form of read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁 磁盘存储、石墨烯存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media includes both persistent and non-volatile, removable and non-removable media that can be implemented by any method or technology for storage of information. Information may be computer-readable instructions, data structures, modules of programs, 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), and 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 tape, magnetic tape storage, graphene storage or other magnetic storage devices or any other non-transmission medium can be used to store information that can be accessed by a computing device. As defined in this article, computer-readable media does not include transitory media, such as modulated data signals and carrier waves.
本领域技术人员应明白,本说明书一个或多个实施例可提供为方法、***或计算机程序产品。因此,本说明书一个或多个实施例可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本说明书一个或多个实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。It should be understood by those skilled in the art that one or more embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, one or more embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment that combines software and hardware aspects. Furthermore, one or more embodiments of the present description may employ a computer program implemented 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. Product form.
本说明书一个或多个实施例可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本本说明书一个或多个实施例,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。One or more embodiments of this 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 specific tasks or implement specific abstract data types. One or more embodiments of the present description may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected 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.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于***实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本说明书的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不必须针对的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。Each embodiment in this specification is described in a progressive manner. The same and similar parts between the various embodiments can be referred to each other. Each embodiment focuses on its differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For relevant details, please refer to the partial description of the method embodiment. In the description of this specification, reference to the terms "one embodiment," "some embodiments," "an example," "specific examples," or "some examples" or the like means that specific features are described in connection with the embodiment or example. , structures, materials or features are included in at least one embodiment or example of this specification. In this specification, the schematic expressions of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the specific features, structures, materials or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, those skilled in the art may combine and combine different embodiments or examples and features of different embodiments or examples described in this specification unless they are inconsistent with each other.
以上所述仅为本说明书一个或多个实施例的实施例而已,并不用于限制本本说明书一个或多个实施例。对于本领域技术人员来说,本说明书一个或多个实施例可以有各种更改和变化。凡在本说明书的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在权利要求范围之内。The above descriptions are only examples of one or more embodiments of this specification, and are not intended to limit one or more embodiments of this specification. To those skilled in the art, various modifications and changes may be made to one or more embodiments of this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification shall be included in the scope of the claims.
Claims (20)
- 一种基于变量状态自动执行合约的方法,所述方法包括:A method for automatically executing contracts based on variable status, the method includes:根据目标交易的执行结果确定目标类型的第一变量的状态发生改变,其中,所述目标交易调用第一合约;The state of the first variable of the target type is determined to change according to the execution result of the target transaction, wherein the target transaction calls the first contract;在所述第一合约的合约状态中确定是否包含针对所述第一变量的回调列表,其中,所述回调列表中的回调项包括回调合约的信息和回调参数;Determine whether the contract status of the first contract contains a callback list for the first variable, wherein the callback items in the callback list include callback contract information and callback parameters;响应于确定包含针对所述第一变量的回调列表,基于所述回调列表中回调项的回调参数,执行回调合约。In response to determining that a callback list for the first variable is included, a callback contract is executed based on a callback parameter of a callback item in the callback list.
- 根据权利要求1所述的方法,其中,所述方法还包括:The method of claim 1, further comprising:接收调用方发送的用于注册回调项的第一交易,所述第一交易调用所述第一合约,其中,所述第一交易包括所述第一变量的变量名、回调合约的回调参数和回调合约的信息;Receive the first transaction sent by the caller for registering a callback item. The first transaction calls the first contract, where the first transaction includes the variable name of the first variable, the callback parameters of the callback contract, and Callback contract information;执行所述第一交易,在针对所述第一变量预先设置的回调列表中添加回调项,其中,所述回调项包括所述回调合约的信息、所述调用方的账户和所述回调参数。The first transaction is executed, and a callback item is added to the callback list preset for the first variable, where the callback item includes information about the callback contract, the caller's account, and the callback parameters.
- 根据权利要求2所述的方法,其中,所述方法还包括:The method of claim 2, further comprising:接收所述调用方发送的用于注销回调项的第二交易,所述第二交易调用所述第一合约,其中,所述第二交易包括所述第一变量的变量名;Receive a second transaction sent by the caller for canceling the callback item, the second transaction calls the first contract, wherein the second transaction includes the variable name of the first variable;执行所述第二交易,在针对所述第一变量对应的回调列表中删除包含所述调用方的账户的回调项。The second transaction is executed, and the callback item containing the caller's account is deleted from the callback list corresponding to the first variable.
- 根据权利要求1所述的方法,其中,所述基于所述回调列表中回调项的回调参数,执行回调合约,包括:The method according to claim 1, wherein executing the callback contract based on the callback parameters of the callback item in the callback list includes:在所述目标交易执行完成后,基于所述回调列表中回调项的回调参数,执行回调合约。After the execution of the target transaction is completed, the callback contract is executed based on the callback parameters of the callback item in the callback list.
- 根据权利要求1所述的方法,其中,所述目标交易为目标区块中的交易,以及The method of claim 1, wherein the target transaction is a transaction in a target block, and所述基于所述回调列表中回调项的回调参数,执行回调合约,包括:Executing the callback contract based on the callback parameters of the callback item in the callback list includes:响应于确定当前时刻所述目标区块中包含的交易没有执行完成,将所述第一变量的变量名添加到预设的待调用列表中;In response to determining that the transaction contained in the target block at the current moment has not been completed, add the variable name of the first variable to the preset to-be-called list;响应于确定当前时刻所述目标区块中包含的交易执行完成,将所述第一变量的变量名添加到所述待调用列表之后,基于所述待调用列表中包含的变量名,从对应变量的回调列表的回调项中确定对应的回调合约和回调参数,并通过确定的回调参数调用 对应的回调合约。In response to determining that the execution of the transaction contained in the target block at the current moment is completed, after adding the variable name of the first variable to the to-be-called list, based on the variable name contained in the to-be-called list, from the corresponding variable Determine the corresponding callback contract and callback parameters in the callback items of the callback list, and call the corresponding callback contract through the determined callback parameters.
- 根据权利要求5所述的方法,其中,所述方法还包括:The method of claim 5, further comprising:对所述待调用列表中包含的变量名对应的回调项进行排序。Sort the callback items corresponding to the variable names included in the to-be-called list.
- 根据权利要求6所述的方法,其中,回调项还包括回调优先级,以及所述对待调用列表中包含的变量名对应的回调项进行排序,包括:The method according to claim 6, wherein the callback items further include callback priorities, and the sorting of callback items corresponding to variable names contained in the to-be-called list includes:根据待调用列表中各变量名对应的回调项的回调优先级,对所述待调用列表中包含的各变量名对应的回调项进行排序。The callback items corresponding to each variable name included in the to-be-called list are sorted according to the callback priorities of the callback items corresponding to each variable name in the to-be-called list.
- 根据权利要求6所述的方法,其中,所述对所述待调用列表中包含的变量名对应的回调项进行排序,包括:The method according to claim 6, wherein sorting the callback items corresponding to the variable names contained in the to-be-called list includes:根据待调用列表中各变量名对应的回调项的回调合约、回调方账户,以及目标交易所在的目标区块的区块号,计算哈希;Calculate the hash based on the callback contract of the callback item corresponding to each variable name in the to-be-called list, the callback party account, and the block number of the target block where the target transaction is located;根据哈希的计算结果,对所述待调用列表中包含的变量名对应的回调项进行排序。According to the hash calculation result, the callback items corresponding to the variable names included in the to-be-called list are sorted.
- 根据权利要求1所述的方法,其中,所述第一变量为隐私计算中的数据访问授权量,以及所述回调合约用于判断当前时刻数据访问授权量是否超过预设的数量阈值,当数据访问授权量超过所述数量阈值时,调用预设的工作流合约,其中,所述工作流合约用于进行隐私计算的相关操作。The method according to claim 1, wherein the first variable is the data access authorization amount in privacy calculation, and the callback contract is used to determine whether the data access authorization amount at the current moment exceeds a preset quantity threshold. When the data When the amount of access authorization exceeds the quantity threshold, a preset workflow contract is called, where the workflow contract is used to perform operations related to privacy calculations.
- 一种基于变量状态自动执行合约的装置,所述装置包括:A device for automatically executing contracts based on variable states, the device includes:第一确定单元,配置为根据目标交易的执行结果确定目标类型的第一变量的状态发生改变,其中,所述目标交易调用第一合约;The first determination unit is configured to determine the change in the state of the first variable of the target type based on the execution result of the target transaction, wherein the target transaction calls the first contract;第二确定单元,配置为在所述第一合约的合约状态中确定是否包含针对所述第一变量的回调列表,其中,所述回调列表中的回调项包括回调合约的信息和回调参数;A second determination unit configured to determine whether a callback list for the first variable is included in the contract state of the first contract, wherein the callback items in the callback list include callback contract information and callback parameters;执行单元,配置为响应于确定包含针对所述第一变量的回调列表,基于所述回调列表中回调项的回调参数,执行回调合约。An execution unit configured to execute a callback contract based on a callback parameter of a callback item in the callback list in response to determining that the callback list contains the first variable.
- 根据权利要求10所述的装置,其中,所述装置还包括:The device of claim 10, wherein the device further comprises:第一接收单元,配置为接收调用方发送的用于注册回调项的第一交易,所述第一交易调用所述第一合约,其中,所述第一交易包括所述第一变量的变量名、回调合约的回调参数和回调合约的信息;The first receiving unit is configured to receive the first transaction sent by the caller for registering a callback item. The first transaction calls the first contract, wherein the first transaction includes the variable name of the first variable. , the callback parameters of the callback contract and the information of the callback contract;添加单元,配置为执行所述第一交易,在针对所述第一变量预先设置的回调列表中添加回调项,其中,所述回调项包括所述回调合约的信息、所述调用方的账户和所 述回调参数。An adding unit configured to execute the first transaction and add a callback item in the callback list preset for the first variable, wherein the callback item includes information about the callback contract, the caller's account, and The callback parameters.
- 根据权利要求11所述的装置,其中,所述装置还包括:The device of claim 11, further comprising:第二接收单元,配置为接收所述调用方发送的用于注销回调项的第二交易,所述第二交易调用所述第一合约,其中,所述第二交易包括所述第一变量的变量名;The second receiving unit is configured to receive the second transaction sent by the caller for canceling the callback item, the second transaction calls the first contract, wherein the second transaction includes the first variable variable name;删除单元,配置为执行所述第二交易,在针对所述第一变量对应的回调列表中删除包含所述调用方的账户的回调项。A deletion unit configured to execute the second transaction and delete the callback item containing the caller's account from the callback list corresponding to the first variable.
- 根据权利要求10所述的装置,其中,所述执行单元进一步配置为:The device of claim 10, wherein the execution unit is further configured to:在所述目标交易执行完成后,基于所述回调列表中回调项的回调参数,执行回调合约。After the execution of the target transaction is completed, the callback contract is executed based on the callback parameters of the callback item in the callback list.
- 根据权利要求10所述的装置,其中,所述目标交易为目标区块中的交易,以及The apparatus of claim 10, wherein the target transaction is a transaction in a target block, and所述执行单元包括:The execution unit includes:变量名添加模块,配置为响应于确定当前时刻所述目标区块中包含的交易没有执行完成,将所述第一变量的变量名添加到预设的待调用列表中;A variable name adding module configured to add the variable name of the first variable to a preset to-be-called list in response to determining that the transaction contained in the target block at the current moment has not been completed;合约调用模块,配置为响应于确定当前时刻所述目标区块中包含的交易执行完成,将所述第一变量的变量名添加到所述待调用列表之后,基于所述待调用列表中包含的变量名,从对应变量的回调列表的回调项中确定对应的回调合约和回调参数,并通过确定的回调参数调用对应的回调合约。The contract calling module is configured to, in response to determining that the transaction contained in the target block at the current moment has been executed, after adding the variable name of the first variable to the to-be-called list, based on the value contained in the to-be-called list. For the variable name, determine the corresponding callback contract and callback parameters from the callback items in the callback list of the corresponding variable, and call the corresponding callback contract through the determined callback parameters.
- 根据权利要求14所述的装置,其中,所述装置还包括:The device of claim 14, wherein the device further comprises:排序模块,配置为对所述待调用列表中包含的变量名对应的回调项进行排序。A sorting module configured to sort the callback items corresponding to the variable names included in the to-be-called list.
- 根据权利要求15所述的装置,其中,回调项还包括回调优先级,以及所述排序模块进一步配置为:The device according to claim 15, wherein the callback item further includes a callback priority, and the sorting module is further configured to:根据待调用列表中各变量名对应的回调项的回调优先级,对所述待调用列表中包含的各变量名对应的回调项进行排序。The callback items corresponding to each variable name included in the to-be-called list are sorted according to the callback priorities of the callback items corresponding to each variable name in the to-be-called list.
- 根据权利要求15所述的装置,其中,所述排序模块进一步配置为:The device of claim 15, wherein the sorting module is further configured to:根据待调用列表中各变量名对应的回调项的回调合约、回调方账户,以及目标交易所在的目标区块的区块号,计算哈希;Calculate the hash based on the callback contract of the callback item corresponding to each variable name in the to-be-called list, the callback party account, and the block number of the target block where the target transaction is located;根据哈希的计算结果,对所述待调用列表中包含的变量名对应的回调项进行排序。According to the calculation result of the hash, the callback items corresponding to the variable names included in the to-be-called list are sorted.
- 根据权利要求10所述的装置,其中,所述第一变量为隐私计算中的数据访问授权量,以及所述回调合约用于判断当前时刻数据访问授权量是否超过预设的数量阈值,当数据访问授权量超过所述数量阈值时,调用预设的工作流合约,其中,所述工作流合约用于进行隐私计算的相关操作。The device according to claim 10, wherein the first variable is the data access authorization amount in privacy calculation, and the callback contract is used to determine whether the data access authorization amount at the current moment exceeds a preset quantity threshold. When the data When the amount of access authorization exceeds the quantity threshold, a preset workflow contract is called, where the workflow contract is used to perform operations related to privacy calculations.
- 一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行权利要求1-9中任一项所述的方法。A computer-readable storage medium on which a computer program is stored. When the computer program is executed in a computer, the computer is caused to perform the method described in any one of claims 1-9.
- 一种区块链的节点,包括存储器和处理器,其特征在于,所述存储器中存储有可执行代码,所述处理器执行所述可执行代码时,实现权利要求1-9中任一项所述的方法。A node of a blockchain, including a memory and a processor, characterized in that executable code is stored in the memory, and when the processor executes the executable code, any one of claims 1-9 is implemented the method described.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210600436.9 | 2022-05-30 | ||
CN202210600436.9A CN114968422A (en) | 2022-05-30 | 2022-05-30 | Method and device for automatically executing contracts based on variable state |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2023231342A1 true WO2023231342A1 (en) | 2023-12-07 |
Family
ID=82958417
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2022/135342 WO2023231342A1 (en) | 2022-05-30 | 2022-11-30 | Method and apparatus for automatically executing contract on the basis of variable state |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN114968422A (en) |
WO (1) | WO2023231342A1 (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114968422A (en) * | 2022-05-30 | 2022-08-30 | 蚂蚁区块链科技(上海)有限公司 | Method and device for automatically executing contracts based on variable state |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20180068359A1 (en) * | 2016-08-04 | 2018-03-08 | Elixsys Group LLC | Systems and methods for using smart contracts to control the trade, supply, manufacture, and distribution of commodities |
CN110929229A (en) * | 2019-11-26 | 2020-03-27 | 中国石油大学(华东) | Block chain-based office document credibility verification method and system |
CN112819621A (en) * | 2021-01-22 | 2021-05-18 | 支付宝(杭州)信息技术有限公司 | Intelligent contract resource loss testing method and system |
CN114968422A (en) * | 2022-05-30 | 2022-08-30 | 蚂蚁区块链科技(上海)有限公司 | Method and device for automatically executing contracts based on variable state |
-
2022
- 2022-05-30 CN CN202210600436.9A patent/CN114968422A/en active Pending
- 2022-11-30 WO PCT/CN2022/135342 patent/WO2023231342A1/en unknown
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20180068359A1 (en) * | 2016-08-04 | 2018-03-08 | Elixsys Group LLC | Systems and methods for using smart contracts to control the trade, supply, manufacture, and distribution of commodities |
CN110929229A (en) * | 2019-11-26 | 2020-03-27 | 中国石油大学(华东) | Block chain-based office document credibility verification method and system |
CN112819621A (en) * | 2021-01-22 | 2021-05-18 | 支付宝(杭州)信息技术有限公司 | Intelligent contract resource loss testing method and system |
CN114968422A (en) * | 2022-05-30 | 2022-08-30 | 蚂蚁区块链科技(上海)有限公司 | Method and device for automatically executing contracts based on variable state |
Also Published As
Publication number | Publication date |
---|---|
CN114968422A (en) | 2022-08-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP6912583B2 (en) | Service processing method and equipment | |
CA3048739C (en) | Blockchain-based data processing method and equipment | |
EP3547129A1 (en) | Block chain consensus method and device | |
JP2020512610A (en) | Blockchain service acceptance and consensus method and device | |
TWI694700B (en) | Data processing method and device, user terminal | |
TWI679581B (en) | Method and device for task execution | |
US20130007773A1 (en) | Systems, methods, apparatuses, and computer program products for facilitating integration of third party technology with a database | |
CN114827165B (en) | Method and block link point for grouping multiple transactions | |
TW201944314A (en) | Payment process configuration and execution method, apparatus and device | |
WO2023160083A1 (en) | Method for executing transactions, blockchain, master node, and slave node | |
TWI697223B (en) | Data processing method | |
JP2014528116A (en) | Distributed resource management in portable computing devices | |
WO2023160085A1 (en) | Method for executing transaction, blockchain, master node, and slave node | |
WO2020199709A1 (en) | Method and system for refershing cascaded cache, and device | |
WO2020119307A1 (en) | Task scheduling method and apparatus based on dsp | |
WO2023231342A1 (en) | Method and apparatus for automatically executing contract on the basis of variable state | |
WO2024051270A1 (en) | Task execution method, apparatus, storage medium, and electronic device | |
CN108427737A (en) | A kind of data clearing method, equipment and computer-readable medium | |
CN111294377B (en) | Dependency network request sending method, terminal device and storage medium | |
WO2024001025A1 (en) | Pre-execution cache data cleaning method and blockchain node | |
CN111459573B (en) | Method and device for starting intelligent contract execution environment | |
WO2023240933A1 (en) | Distributed application deployment method and apparatus based on blockchain | |
WO2024001032A1 (en) | Method for executing transaction in blockchain system, and blockchain system and nodes | |
WO2023185041A1 (en) | Data processing method and apparatus, electronic device, and storage medium | |
CN116032756A (en) | Method for updating configuration information of application program based on block chain and block chain link point |
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: 22944643 Country of ref document: EP Kind code of ref document: A1 |