WO2022206433A1 - 一种在Fabric区块链中预执行链码的方法和装置 - Google Patents

一种在Fabric区块链中预执行链码的方法和装置 Download PDF

Info

Publication number
WO2022206433A1
WO2022206433A1 PCT/CN2022/081722 CN2022081722W WO2022206433A1 WO 2022206433 A1 WO2022206433 A1 WO 2022206433A1 CN 2022081722 W CN2022081722 W CN 2022081722W WO 2022206433 A1 WO2022206433 A1 WO 2022206433A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
chaincode
chain code
proposal
transaction proposal
Prior art date
Application number
PCT/CN2022/081722
Other languages
English (en)
French (fr)
Inventor
余逸荣
Original Assignee
支付宝(杭州)信息技术有限公司
蚂蚁区块链科技(上海)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 支付宝(杭州)信息技术有限公司, 蚂蚁区块链科技(上海)有限公司 filed Critical 支付宝(杭州)信息技术有限公司
Publication of WO2022206433A1 publication Critical patent/WO2022206433A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/04Payment circuits
    • G06Q20/06Private payment circuits, e.g. involving electronic currency used among participants of a common payment scheme
    • G06Q20/065Private payment circuits, e.g. involving electronic currency used among participants of a common payment scheme using e-cash
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3823Payment protocols; Details thereof insuring higher security of transaction combining multiple encryption tools for a transaction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]

Definitions

  • the embodiments of this specification relate to the field of blockchain technology, and more particularly, to a method and apparatus for invoking chaincode in Fabric blockchain, and a method and apparatus for pre-executing chaincode in Fabric blockchain.
  • Hyperledger Fabric blockchain (hereinafter referred to as Fabric blockchain) is an enterprise-oriented consortium chain.
  • the Fabric blockchain includes the following types of nodes: client nodes, peer nodes, orderer nodes, and so on.
  • the peer nodes further include an endorsement (Endorsor) node, an management (Anchor) node, a commit (Committer) node, and the like.
  • the Fabric blockchain includes multiple channels, and each channel has its own closed ledger data and chaincode, which is the smart contract in the Fabric blockchain. Peers can choose which channels to join, and they can join the channel after being authenticated by peers already in the channel.
  • a client node can initiate a transaction proposal to a channel in the Fabirc blockchain, so that the client node sends a transaction proposal to at least one endorsing node in the channel.
  • the endorsement node in the channel has a transaction proposal system interface, so that the endorsement node can pre-execute and digitally sign the transaction proposal received from the client node by calling the system interface, and return the pre-execution result and digital signature after the pre-execution. to the client node.
  • the client node sends the transaction pre-execution result and signature to the ordering node after receiving it from each endorsement node.
  • the sorting node is used to sort transactions, and pack the sorted transactions into blocks at fixed time intervals and send them to the management node.
  • each peer node After receiving the block, the management node broadcasts the block to each submitting node. After the submitting node receives the block, it verifies the execution status of each transaction in the block, marks its execution status in each transaction of the block, and then adds the block to the node's ledger data (ie, submits the block).
  • each peer node is a commit node, that is, each peer node locally includes the ledger data of the channel.
  • the invokechaincode interface is provided in the Fabric blockchain so that the chaincodes can call each other.
  • the customer chaincode is invoked between the chaincodes to run the third-party service chaincode logic to Affect and modify the state database of the third-party service chaincode, or run the third-party service chaincode logic to store the ledger data to use the third-party service.
  • the third-party service chain code it is necessary for the third-party service chain code to authenticate the chain code that calls it.
  • the Fabric blockchain provides the function of obtaining the identity of the user account that initiates the transaction proposal, which can verify the account information of the transaction initiator.
  • the third-party service chain code calls the GetCreator interface to obtain the account information of the transaction proposer; the third-party service chain code uses and processes the account information that initiates the proposal.
  • the embodiments of this specification aim to provide a more effective solution for invoking and pre-executing chain codes in the Fabric blockchain, so as to solve the deficiencies in the prior art.
  • one aspect of this specification provides a method for invoking a chaincode in a Fabric blockchain, where the Fabric blockchain includes a client node and an endorsement node, and the method is executed by the client node, Including: generating a transaction proposal for a first transaction, the transaction proposal includes a call to the first chaincode, the first chaincode includes a call to a second chaincode, and the second chaincode includes A call to a predetermined system chain code, the predetermined system chain code is used to obtain the transaction proposal of the transaction being executed during execution; and the transaction proposal of the first transaction is sent to the endorsement node.
  • the method further includes, after generating a transaction proposal for the first transaction, generating a signature for the transaction proposal, wherein sending the transaction proposal for the first transaction to the endorsing node includes: A transaction proposal and the signature for the first transaction are sent to the endorsing node.
  • Another aspect of the present specification provides a method for pre-executing chain code in a Fabric blockchain, where the Fabric blockchain includes a client node and an endorsement node, the method is executed by the endorsement node, including: from a client The end node receives the transaction proposal of the first transaction, the transaction proposal includes a call to the first chaincode, the first chaincode includes a call to the second chaincode, and the second chaincode includes a call to the predetermined chaincode.
  • Invocation of the system chain code after starting to pre-execute the second chain code in the first transaction, obtain the transaction proposal of the first transaction by pre-executing the predetermined system chain code; obtain from the transaction proposal The name of the first chain code; corresponding processing is performed based on the name of the first chain code.
  • the second chain code is only used to be called by a predetermined chain code, wherein performing corresponding processing based on the name of the first chain code includes determining whether the first chain code is the Predetermining a chain code, and determining whether to end the pre-execution of the second chain code based on the result of the judgment.
  • performing corresponding processing based on the name of the first chaincode includes writing the name of the first chaincode into a read set or a write set of the transaction.
  • the second chain code is a chain code used for sending cross-chain messages.
  • receiving the transaction proposal for the first transaction from the client node includes receiving, from the client node, the transaction proposal for the first transaction and the client node's signature on the transaction proposal, and the method further includes , verify the signature.
  • Another aspect of this specification provides an apparatus for invoking a chain code in a Fabric blockchain, where the Fabric blockchain includes a client node and an endorsement node, the device is deployed on the client node, and includes: a generating unit , configured to generate a transaction proposal for the first transaction, the transaction proposal includes a call to the first chaincode, the first chaincode includes a call to the second chaincode, the second chaincode including a call to a predetermined system chain code, the predetermined system chain code is used to obtain the transaction proposal of the transaction being executed during execution; the sending unit is configured to send the transaction proposal of the first transaction to the endorsement node .
  • a generating unit configured to generate a transaction proposal for the first transaction, the transaction proposal includes a call to the first chaincode, the first chaincode includes a call to the second chaincode, the second chaincode including a call to a predetermined system chain code, the predetermined system chain code is used to obtain the transaction proposal of the transaction being executed during execution; the sending unit is configured to send the transaction proposal of the first transaction
  • the apparatus further includes a signature unit configured to, after generating the transaction proposal of the first transaction, generate a signature for the transaction proposal, wherein the sending unit is further configured to send the transaction proposal to the first transaction.
  • the endorsing node sends the transaction proposal and the signature of the first transaction.
  • Another aspect of this specification provides an apparatus for pre-executing chain codes in a Fabric blockchain, where the Fabric blockchain includes a client node and an endorsement node, the device is deployed on the endorsement node, and includes: a receiving unit , configured to receive a transaction proposal of the first transaction from the client node, the transaction proposal includes a call to the first chaincode, the first chaincode includes a call to the second chaincode, the second chaincode
  • the chain code includes a call to a predetermined system chain code;
  • the first obtaining unit is configured to, after starting to pre-execute the second chain code in the first transaction, obtain the predetermined system chain code by pre-executing the a transaction proposal of the first transaction; a second obtaining unit, configured to obtain the name of the first chaincode from the transaction proposal; and a processing unit, configured to perform corresponding processing based on the name of the first chaincode .
  • the second chain code is only used to be called by a predetermined chain code
  • the processing unit is further configured to determine whether the first chain code is the predetermined chain code, based on the The result of the judgment determines whether to end the pre-execution of the second chain code.
  • the processing unit is further configured to write the name of the first chaincode into a read set or a write set of the transaction.
  • the receiving unit is further configured to receive, from the client node, a transaction proposal of the first transaction and the client node's signature on the transaction proposal, and the apparatus further includes a verification unit configured to to verify the signature.
  • Another aspect of the present specification provides a computer-readable storage medium on which a computer program or instruction is stored, and when the computer program or instruction is executed in a computer, causes the computer to execute any one of the above methods.
  • Another aspect of the present specification provides a computing device comprising a memory and a processor, wherein the memory stores a computer program or instruction, and the processor implements any of the above methods when executing the computer program or instruction.
  • the system chaincode call is performed by writing the system chaincode interface GetSignedProposal in the called chaincode, the content of the original proposal is obtained, and the name of the called chaincode is extracted from it , so as to identify the identity of the caller chaincode for subsequent processing based on the name of the caller chaincode.
  • FIG. 1 shows a schematic diagram of a Fabric blockchain system according to an embodiment of the present specification
  • FIG. 2 shows a flowchart of a method for invoking a chaincode in a Fabric blockchain according to an embodiment of the present specification
  • FIG. 3 shows a flowchart of a method for pre-executing chaincodes in a Fabric blockchain according to an embodiment of the present specification
  • FIG. 4 shows an apparatus 400 for invoking a chaincode in a Fabric blockchain according to an embodiment of the present specification
  • FIG. 5 shows an apparatus 500 for pre-executing chain codes in a Fabric blockchain according to an embodiment of the present specification.
  • FIG. 1 shows a schematic diagram of a Fabric blockchain system according to an embodiment of the present specification.
  • the system includes user equipment 12 and a channel 11 in the Fabric blockchain.
  • the user equipment 12 may be a client node of the Fabric blockchain, which may be a user's device of the Fabric blockchain, a node device of other blockchains, or used to transfer messages between multiple blockchains
  • the repeater equipment, etc. are not limited here.
  • the channel 11 includes, for example, a node device 1, a node device 2, and a node device 3 serving as an endorsement node.
  • the user equipment 12 may deposit data into the ledger data of the channel 11 by sending a transaction proposal to at least one endorsing node in the channel 11 .
  • the transaction proposal is, for example, a transaction proposal of transaction 1, and the transaction proposal includes a call to chaincode 1.
  • Chaincode 1 is, for example, a cross-chain transfer chaincode, in which chaincode 2 is called, and chaincode 2 is, for example, a chaincode used to send cross-chain messages.
  • Chaincode 1 calls chaincode 2 to send the message of cross-chain transfer to off-chain.
  • chain code 2 when chain code 2 is executed, it is impossible to know which chain code calls chain code 2, so that chain code 2 cannot obtain the name of chain code 1, thereby affecting cross-chain transfers. implementation.
  • the transaction proposal of the transaction 1 can be obtained, and the chaincode 1 can be obtained from the transaction proposal. name, so as to facilitate the implementation of cross-chain transfers.
  • FIG. 1 schematically shows a process diagram of pre-executing transaction 1 in endorsement node 2. During the process of executing transaction 1, chain code 1 called therein is executed, and then chain code 2 in chain code 1 is executed.
  • Fig. 2 shows a flowchart of a method for invoking a chaincode in a Fabric blockchain according to an embodiment of the present specification, where the Fabric blockchain includes a user equipment 12 serving as a client node and a node device 2 serving as an endorsement node , the method is executed by the user equipment 12, including: step S202, generating a transaction proposal of transaction 1, the transaction proposal includes a call to the chain code 1, and the chain code 1 includes a call to the chain code 2 , the chain code 2 includes a call to the system chain code 3, and the system chain code 3 is used to obtain the transaction proposal of the transaction being executed during execution;
  • Step S204 send the transaction proposal of transaction 1 to node device 2.
  • step S202 a transaction proposal for transaction 1 is generated, the transaction proposal includes a call to the chain code 1, the chain code 1 includes a call to the chain code 2, and the chain code 2 includes a call to the system Invocation of chaincode 3, the system chaincode 3 is used to obtain the transaction proposal of the transaction being executed during execution.
  • chain code 1 is, for example, a chain code for cross-chain transfer
  • chain code 2 is, for example, a chain code for sending cross-chain messages.
  • the message of the chain transfer is sent to the outside of the chain.
  • user 1 corresponding to user device 12 wishes to transfer money to user 2 in another blockchain (or another channel of the Fabric blockchain)
  • user 1 When user 1 corresponding to user device 12 wishes to transfer money to user 2 in another blockchain (or another channel of the Fabric blockchain), user 1 generates a transaction proposal for transaction 1 through user device 12, where Chaincode 1 is called in the transaction proposal, and the amount to be transferred out of this channel, the blockchain that receives the transfer, and the blockchain account (that is, the user 2 account) are passed to the chaincode 1 as incoming parameters.
  • Chaincode 2 is called in chaincode 1 to store the name of chaincode 1, the amount, the blockchain ID and blockchain account for receiving the transfer into the ledger database of channel 11, so as to send the chain code out of the chain. information.
  • the system call interface GetSignedProposal of system chain code 3 is pre-written in chain code 2, so that chain code 2 can pre-execute system chain code 3 through this call interface when chain code 2 is pre-executed, so as to obtain the signature issued by user 1 and signed by user 1. , obtain the name of chaincode 1 from it, and generate the above-mentioned message sent off-chain based on the name of chaincode 1.
  • channel 11 is not limited to calling chaincode 2 only by chaincode 1 to send messages outside the chain.
  • channel 11 may include multiple client chain codes, chain code 2 is a third-party service chain code, and each client chain code can call chain code 2 to use the cross-chain message sending service provided by the chain code .
  • the chain code 2 is not limited to a chain code used for cross-chain services, but may also be a chain code used for services within the channel 11 .
  • chain code 1 is the chain code used for RMB-USD exchange
  • the account status of chain code 1 records the RMB account balance of each user
  • chain code 2 is the chain code used for USD-RMB exchange.
  • the account status of 2 records the USD account balance of each user.
  • user 1 wishes to convert a predetermined amount in his RMB account into US dollars, he generates a transaction proposal for transaction 1, in which chaincode 1 is invoked to convert the amount of RMB to be converted As the incoming parameter of this chaincode 1.
  • the system interface GetSignedProposal is written in the chaincode 2 to call the system chaincode 3, so that the chaincode 2 can obtain the name of the chaincode that calls it through the pre-execution system chaincode 3 during pre-execution, and determine whether the name is is the name of chain code 1, if it is the name of chain code 1, it can continue to execute, if not, end the execution. That is to say, in this embodiment, in order to ensure the security of fund exchange, chain code 2 is only allowed to be called by chain code 1, and chain code 2 needs to obtain the name of the chain code that calls its chain code during execution to determine the chain code. Whether the code is chain code 1, thus, chain code 2 obtains the name of the chain code that calls it by calling system chain code 3.
  • the user equipment 12 After generating the transaction proposal for transaction 1, the user equipment 12 signs the transaction proposal using the private key of the blockchain account of its channel 11.
  • step S204 the transaction proposal of transaction 1 is sent to node device 2.
  • the user equipment 12 After the user equipment 12 generates the transaction proposal of transaction 1, it can send the transaction proposal to at least one endorsement node (ie, the node device of the endorsement node). For example, the user equipment 12 sends the transaction of transaction 1 to the node device 2 in FIG. 1 . proposal. Specifically, after generating the transaction proposal of transaction 1 and its signature, the user equipment 12 sends the transaction proposal and its signature to at least one endorsing node.
  • endorsement node ie, the node device of the endorsement node.
  • the user equipment 12 sends the transaction of transaction 1 to the node device 2 in FIG. 1 .
  • proposal Specifically, after generating the transaction proposal of transaction 1 and its signature, the user equipment 12 sends the transaction proposal and its signature to at least one endorsing node.
  • FIG. 3 shows a flowchart of a method for pre-executing chaincodes in a Fabric blockchain according to an embodiment of the present specification, where the Fabric blockchain includes a user equipment 12 serving as a client node and a node device serving as an endorsement node 2.
  • the method is executed by the node device 2, including: step S302, receiving a transaction proposal of the transaction 1 from the user equipment 12, the transaction proposal includes a call to the chain code 1, and the chain code 1 includes the chain code 1. 2, the chain code 2 includes a call to the system chain code 3;
  • Step S304 after starting to pre-execute the chain code 2 in the transaction 1, obtain the transaction proposal of the transaction 1 by pre-executing the system chain code 3;
  • Step S306 obtain the name of the chain code 1 from the transaction proposal;
  • step S308, perform corresponding processing based on the name of the chain code 1.
  • the endorsement node pre-executes the transaction, and obtains the pre-execution read and write set, but The read-write set is not stored in the ledger data.
  • the pre-execution of each transaction is verified based on the transaction sequence. If the verification is passed, the transaction is marked as valid, and the transaction proposal of the transaction, read The write set and transaction execution status (that is, whether the transaction is valid) are stored in the ledger data. Therefore, in the Fabric blockchain, the pre-execution process of the transaction is also the execution process of the transaction.
  • step S302 a transaction proposal of transaction 1 is received from the user equipment 12, the transaction proposal includes a call to chaincode 1, the chaincode 1 includes a call to chaincode 2, and the chaincode 2 in Includes calls to system chaincode 3.
  • step S202 for the specific description of transaction 1, reference may be made to the description of step S202 above, which will not be repeated here.
  • the node device 2 In addition to receiving the transaction proposal of transaction 1 from the user equipment 12, the node device 2 also receives the signature of the user equipment 12 for the transaction proposal.
  • Step S304 after starting to pre-execute the chain code 2 in the transaction 1, obtain the transaction proposal of the transaction 1 by pre-executing the system chain code 3.
  • the node device 2 can use the public key corresponding to the user equipment 12 to verify the signature of the received transaction proposal to verify whether the transaction proposal is sent by the user equipment 12 and whether the content of the transaction proposal has been tamper.
  • the node device 2 After receiving the transaction proposal of transaction 1 from the user equipment 12 and verifying its signature, the node device 2, as an endorsement node, executes the preset processing process for the transaction proposal relative to the endorsement node, that is, pre-executes transaction 1, and generates a pre-execution process.
  • the read-write set of transaction 1, the read-write set is signed, and the read-write set and the signature are sent back to the user device 12.
  • the chain code 1 is, for example, a chain code for cross-chain transfer, and the incoming parameters to the chain code 1 include the amount to be transferred out of the channel, the blockchain receiving the transfer, and the block chain account.
  • pre-executing chaincode 1 first read the account balance of user 1 corresponding to user equipment 12, record the read account balance in the read set of pre-execution transaction 1, and reduce the account balance of user 1 by the amount and record the changes to user 1's account balance in the write set of pre-executed transaction 1. Then, through the call to chain code 2 in chain code 1, chain code 2 is executed to send transfer messages outside the chain.
  • the chain code 2 is, for example, a chain code for sending a cross-chain message. It is not limited to being called by chaincode 1, but can be called by various chaincodes in channel 11. In this case, it is necessary to indicate in the cross-chain message which chain code in channel 11 is called by chain code 2. Different chain codes correspond to different processing procedures outside the chain. For example, for chain code 1, Corresponding transfer processing is preset outside the chain. Therefore, only when the name of the chain code that calls chain code 2 is determined, the correct subsequent processing of the cross-chain message can be performed. In the embodiment of this specification, the calling interface GetSignedProposal for calling the system chain code 3 is pre-written in the chain code 2, so that the system chain code 3 is called. System chaincode 3 is used to get the transaction proposal of the executing transaction at execution time. Thus, after starting the execution of chaincode 2, the system chaincode 3 called therein is executed, thereby obtaining the transaction proposal of the signed transaction 1.
  • chain code 1 is, for example, a chain code used for RMB-USD exchange
  • chain code 2 is a chain code used for USD-RMB exchange
  • chain code 2 is only allowed to be exchanged by chain code 1. transfer. Therefore, in the process of pre-executing transaction 1, first read the RMB account balance of user 1 through pre-executing chain code 1, record the read account balance in the read set of pre-executing transaction 1, and reduce the need for the account balance. The exchanged amount is recorded in the write set of the pre-executed transaction 1, and the change of the balance of the RMB account of the corresponding user 1 is recorded, and then through the call of the chain code 1 to the chain code 2, the chain code 2 is pre-executed to change the USD account of the user 1.
  • step S306 the name of the chain code 1 is obtained from the transaction proposal.
  • step S308 corresponding processing is performed based on the name of the chain code 1.
  • chain code 1 is, for example, a chain code for cross-chain transfer
  • chain code 2 is, for example, a chain code for sending cross-chain messages.
  • node device 2 After obtaining the name of chain code 1 through pre-execution system chain code 3, record in the read set or write set of pre-execution transaction 1: the name of chain code 1, the amount of money transferred out of this channel, the receiving The blockchain and blockchain account of the transfer, and after the pre-execution is completed, the acquired read-write set is signed.
  • user equipment 12 broadcasts the transaction content of transaction 1, where the transaction content includes the transaction proposal and pre-execution read-write set of transaction 1.
  • the off-chain device can obtain the read/write set of transaction 1 by querying the content of transaction 1 in channel 11, and then perform cross-chain transfer processing corresponding to chain code 1 based on the name of chain code 1 recorded therein.
  • chain code 1 is, for example, a chain code used for RMB-USD exchange
  • chain code 2 is a chain code used for USD-RMB exchange
  • chain code 2 is only allowed to be exchanged by chain code 1. transfer. Therefore, after pre-executing system chaincode 3 and obtaining the name of chaincode 1, determine whether the name is the name of chaincode 1, and if so, continue to pre-execute transaction 1, that is, change the USD account balance of user 1, and Record in the read-write set, if not, record the exchange failure in the pre-execution write set, and end the pre-execution of transaction 1.
  • FIG. 4 shows an apparatus 400 for invoking a chaincode in a Fabric blockchain according to an embodiment of the present specification, where the Fabric blockchain includes a client node and an endorsement node, and the apparatus 400 is deployed on the client
  • the node includes: a generating unit 41, configured to generate a transaction proposal of a first transaction, the transaction proposal includes a call to the first chaincode, and the first chaincode includes a call to the second chaincode , the second chain code includes a call to a predetermined system chain code, the predetermined system chain code is used to obtain a transaction proposal of the transaction being executed during execution; the sending unit 42 is configured to send to the endorsement node.
  • the transaction proposal of the first transaction includes: a generating unit 41, configured to generate a transaction proposal of a first transaction, the transaction proposal includes a call to the first chaincode, and the first chaincode includes a call to the second chaincode , the second chain code includes a call to a predetermined system chain code, the predetermined system chain code is used to obtain a transaction proposal
  • the apparatus 400 further includes a signature unit 43 configured to, after generating the transaction proposal of the first transaction, generate a signature for the transaction proposal, wherein the sending unit 42 is further configured to , and send the transaction proposal and the signature of the first transaction to the endorsing node.
  • FIG. 5 shows an apparatus 500 for pre-executing chaincode in a Fabric blockchain according to an embodiment of the present specification, where the Fabric blockchain includes a client node and an endorsement node, and the apparatus 500 is deployed in the endorsement node, including: a receiving unit 51, configured to receive a transaction proposal of a first transaction from a client node, the transaction proposal includes a call to the first chaincode, and the first chaincode includes a second chaincode
  • the second chain code includes a call to a predetermined system chain code
  • the first obtaining unit 52 is configured to, after starting to pre-execute the second chain code in the first transaction, pre-execute the Predetermining the system chain code, and obtaining the transaction proposal of the first transaction
  • the second obtaining unit 53 is configured to obtain the name of the first chain code from the transaction proposal
  • the processing unit 54 is configured to, based on the The name of the first chaincode is processed accordingly.
  • the second chain code is only used to be called by a predetermined chain code
  • the processing unit 54 is further configured to determine whether the first chain code is the predetermined chain code, based on the The result of the judgment determines whether to end the pre-execution of the second chain code.
  • processing unit 54 is further configured to write the name of the first chaincode into the read set or write set of the transaction.
  • the receiving unit 51 is further configured to receive, from the client node, a transaction proposal of the first transaction and the client node's signature on the transaction proposal, and the apparatus 500 further includes a verification unit 55. Configure to verify the signature.
  • Another aspect of the present specification provides a computer-readable storage medium on which a computer program or instruction is stored, and when the computer program or instruction is executed in a computer, causes the computer to execute any one of the above methods.
  • Another aspect of the present specification provides a computing device, including a memory and a processor, where a computer program or instruction is stored in the memory, and the processor implements any one of the above methods when executing the computer program or instruction.
  • the system chaincode call is performed by writing the system chaincode interface GetSignedProposal in the called chaincode, the content of the original proposal is obtained, and the chaincode of the initial call is extracted from it , so as to identify the identity of the caller chaincode for subsequent processing based on the name of the caller chaincode.
  • a software module can be placed in random access memory (RAM), internal memory, read only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other in the technical field. in any other known form of storage medium.
  • RAM random access memory
  • ROM read only memory
  • electrically programmable ROM electrically erasable programmable ROM
  • registers hard disk, removable disk, CD-ROM, or any other in the technical field. in any other known form of storage medium.

Landscapes

  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Engineering & Computer Science (AREA)
  • Finance (AREA)
  • Physics & Mathematics (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Technology Law (AREA)
  • Development Economics (AREA)
  • Computer Security & Cryptography (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

本说明书实施例提供了一种在Fabric区块链中预执行链码的方法和装置,所述Fabric区块链中包括客户端节点和背书节点,所述方法由所述背书节点执行,包括:从客户端节点接收第一交易的交易提案,所述交易提案中包括对第一链码的调用,所述第一链码中包括对第二链码的调用,所述第二链码中包括对预定系统链码的调用;在开始预执行所述第一交易中的第二链码之后,通过预执行所述预定系统链码,获取所述第一交易的交易提案;从所述交易提案中获取所述第一链码的名称;基于所述第一链码的名称进行相应的处理。

Description

一种在Fabric区块链中预执行链码的方法和装置 技术领域
本说明书实施例涉及区块链技术领域,更具体地,涉及一种在Fabric区块链中调用链码的方法和装置、以及一种在Fabric区块链中预执行链码的方法和装置。
背景技术
Hyperledger Fabric区块链(下文简称为Fabric区块链)是一种面向企业的联盟链。Fabric区块链中包括以下多种类型的节点:客户端节点、对等(Peer)节点、排序(orderer)节点等等。所述对等节点中又包括背书(Endorsor)节点、管理(Anchor)节点、提交(Committer)节点等。Fabric区块链中包括多个通道(channel),每个通道具有自身封闭的账本数据和链码(chaincode),所述链码即为Fabric区块链中的智能合约。对等节点可选择加入哪些通道,其在经过通道中已有的对等节点的身份验证之后可加入该通道。客户端节点可向Fabirc区块链中的某个通道发起交易提案,从而,客户端节点向该通道中的至少一个背书节点发送交易提案。通道中的背书节点具有交易提案系统接口,从而背书节点可通过调用该系统接口对从客户端节点接收的交易提案进行预执行并进行数字签名,并在预执行之后将预执行结果和数字签名返回给所述客户端节点。所述客户端节点在从各个背书节点接收到交易预执行结果和签名之后,将其发送给排序节点。排序节点用于对交易进行排序、并将经排序的交易按照固定的时间间隔打包成区块发送给管理节点。管理节点收到区块之后将区块广播给每个提交节点。提交节点收到区块之后验证区块中每个交易的执行状态,在区块的每个交易中标记其执行状态,然后将区块加入本节点的账本数据中(即,提交区块)。其中,每个对等节点都是提交节点,即,每个对等节点本地都包括通道的账本数据。
Fabric区块链中提供invokechaincode接口使得链码间可以相互调用,当第三方服务链码和客户链码部署在同一个通道时,客户链码通过链码间调用,运行第三方服务链码逻辑来影响和修改第三方服务链码的状态数据库,或者运行第三方服务链码逻辑来存储账本数据,从而使用第三方服务。作为服务提供方,第三方服务链码有必要对调用其的链码进行身份认证,当前Fabric区块链提供获取发起交易提案的用户账号身份功能,可以验证交易发起者的账号信息。具体是,第三方服务链码链码调用GetCreator接口,获取交易提案人账号信息;第三发服务链码对发起提案账号信息进行使用和处理。
因此,需要一种更有效的在Fabric区块链中调用和预执行链码的方案。
发明内容
本说明书实施例旨在提供一种更有效的在Fabric区块链中调用和预执行链码的方案,以解决现有技术中的不足。
为实现上述目的,本说明书一个方面提供一种在Fabric区块链中调用链码的方法,所述Fabric区块链中包括客户端节点和背书节点,所述方法由所述客户端节点执行,包括:生成第一交易的交易提案,所述交易提案中包括对所述第一链码的调用,所述第一链码中包括对第二链码的调用,所述第二链码中包括对预定系统链码的调用,所述预定系统链码用于在执行时获取正在执行的交易的交易提案;向所述背书节点发送所述第一交易的交易提案。
在一种实施方式中,所述方法还包括,在生成第一交易的交易提案之后,生成对所述交易提案的签名,其中,向所述背书节点发送所述第一交易的交易提案包括,向所述背书节点发送所述第一交易的交易提案和所述签名。
本说明书另一方面提供一种在Fabric区块链中预执行链码的方法,所述Fabric区块链中包括客户端节点和背书节点,所述方法由所述背书节点执行,包括:从客户端节点接收第一交易的交易提案,所述交易提案中包括对第一链码的调用,所述第一链码中包括对第二链码的调用,所述第二链码中包括对预定系统链码的调用;在开始预执行所述第一交易中的第二链码之后,通过预执行所述预定系统链码,获取所述第一交易的交易提案;从所述交易提案中获取所述第一链码的名称;基于所述第一链码的名称进行相应的处理。
在一种实施方式中,所述第二链码仅用于被预定链码调用,其中,基于所述第一链码的名称进行相应的处理包括,判断所述第一链码是否为所述预定链码,基于所述判断的结果确定是否结束对所述第二链码的预执行。
在一种实施方式中,基于所述第一链码的名称进行相应的处理包括,将所述第一链码的名称写入所述交易的读集或写集中。
在一种实施方式中,所述第二链码为用于发送跨链消息的链码。
在一种实施方式中,从客户端节点接收第一交易的交易提案包括,从客户端节点接收第一交易的交易提案和所述客户端节点对所述交易提案的签名,所述方法还包括,对 所述签名进行验证。
本说明书另一方面提供一种在Fabric区块链中调用链码的装置,所述Fabric区块链中包括客户端节点和背书节点,所述装置部署于所述客户端节点,包括:生成单元,配置为,生成第一交易的交易提案,所述交易提案中包括对所述第一链码的调用,所述第一链码中包括对第二链码的调用,所述第二链码中包括对预定系统链码的调用,所述预定系统链码用于在执行时获取正在执行的交易的交易提案;发送单元,配置为,向所述背书节点发送所述第一交易的交易提案。
在一种实施方式中,所述装置还包括,签名单元,配置为,在生成第一交易的交易提案之后,生成对所述交易提案的签名,其中,所述发送单元还配置为,向所述背书节点发送所述第一交易的交易提案和所述签名。
本说明书另一方面提供一种在Fabric区块链中预执行链码的装置,所述Fabric区块链中包括客户端节点和背书节点,所述装置部署于所述背书节点,包括:接收单元,配置为,从客户端节点接收第一交易的交易提案,所述交易提案中包括对第一链码的调用,所述第一链码中包括对第二链码的调用,所述第二链码中包括对预定系统链码的调用;第一获取单元,配置为,在开始预执行所述第一交易中的第二链码之后,通过预执行所述预定系统链码,获取所述第一交易的交易提案;第二获取单元,配置为,从所述交易提案中获取所述第一链码的名称;处理单元,配置为,基于所述第一链码的名称进行相应的处理。
在一种实施方式中,所述第二链码仅用于被预定链码调用,其中,所述处理单元还配置为,判断所述第一链码是否为所述预定链码,基于所述判断的结果确定是否结束对所述第二链码的预执行。
在一种实施方式中,所述处理单元还配置为,将所述第一链码的名称写入所述交易的读集或写集中。
在一种实施方式中,所述接收单元还配置为,从客户端节点接收第一交易的交易提案和所述客户端节点对所述交易提案的签名,所述装置还包括,验证单元,配置为,对所述签名进行验证。
本说明书另一方面提供一种计算机可读存储介质,其上存储有计算机程序或指令,当所述计算机程序或指令在计算机中执行时,令计算机执行上述任一种方法。
本说明书另一方面提供一种计算设备,包括存储器和处理器,所述存储器中存储有 计算机程序或指令,所述处理器在执行所述计算机程序或指令时,实现上述任一种方法。
通过根据本说明书实施例的调用和执行链码的方案,通过在被调用链码中写入系统链码接口GetSignedProposal进行系统链码调用,获取原始提案的内容,并从中提取调用的链码的名称,从而识别调用方链码的身份,以便于基于该调用方链码的名称进行后续处理。
附图说明
通过结合附图描述本说明书实施例,可以使得本说明书实施例更加清楚:
图1示出根据本说明书实施例的Fabric区块链系统的示意图;
图2示出根据本说明书实施例的一种在Fabric区块链中调用链码的方法流程图;
图3示出根据本说明书实施例的一种在Fabric区块链中预执行链码的方法流程图;
图4示出根据本说明书实施例的一种在Fabric区块链中调用链码的装置400;
图5示出根据本说明书实施例的一种在Fabric区块链中预执行链码的装置500。
具体实施方式
下面将结合附图描述本说明书实施例。
图1示出根据本说明书实施例的Fabric区块链系统的示意图。如图1中所示,所述系统中包括用户设备12和Fabric区块链中的通道11。其中,用户设备12可以为Fabric区块链的客户端节点,其可以为Fabric区块链的使用用户的设备,其它区块链的节点设备、或者用于在多个区块链之间中转消息的中继器的设备等等,在此不作限定。通道11中例如包括作为背书节点的节点设备1、节点设备2和节点设备3。如上文所述,用户设备12可通过向通道11中的至少一个背书节点发送交易提案以向通道11的账本数据中存入数据。所述交易提案例如为交易1的交易提案,该交易提案中包括对链码1的调用。链码1例如为跨链转账链码,其中调用链码2,链码2例如为用于发送跨链消息的链码,链码1通过调用链码2,而将跨链转账的消息发送给链外。如上文所述,在现有技术中,在执行链码2时,并不能获知是哪个链码调用了链码2,从而使得不能链码2无法获取链码1的名称,从而影响跨链转账的实施。在本说明书实施例中,通过在链码2中调用系统链码3(即通过系统链码接口GetSignedProposal进行调用),从而可获取交易1的交易提案,并从该交易提案中获取链码1的名称,从而便于对跨链转账的实施。
在用户设备12向节点设备1-3发送了交易1的交易提案之后,各个节点设备预执行交易1,生成预执行交易1的读写集,对该读写集进行签名,并将读写集及其签名发送回用户设备12。图1中示意示出在背书节点2中预执行交易1的过程示意图,在执行交易1的过程中,执行其中调用的链码1,之后执行链码1中的链码2。在执行链码2的过程中,通过执行其中调用的系统链码3,从而获取交易1的交易提案,从该交易提案中获取链码1的名称,并基于该链码1的名称继续执行链码2,例如,将链码1的名称写入预执行交易1的读集或写集中,从而该链码1的名称可在后续存入通道11的账本数据中。链下设备在从通道11中查询到该账本数据之后,可从其中读取到该链码1的名称,并基于该链码1的名称进行相应的处理。
可以理解,上文参考图1的描述仅仅是示意性的,而不是限制性的。下面将详细描述根据本说明书实施例的调用和执行链码的方法。
图2示出根据本说明书实施例的一种在Fabric区块链中调用链码的方法流程图,所述Fabric区块链中包括作为客户端节点的用户设备12和作为背书节点的节点设备2,所述方法由用户设备12执行,包括:步骤S202,生成交易1的交易提案,所述交易提案中包括对所述链码1的调用,所述链码1中包括对链码2的调用,所述链码2中包括对系统链码3的调用,所述系统链码3用于在执行时获取正在执行的交易的交易提案;
步骤S204,向节点设备2发送交易1的交易提案。
首先,步骤S202,生成交易1的交易提案,所述交易提案中包括对所述链码1的调用,所述链码1中包括对链码2的调用,所述链码2中包括对系统链码3的调用,所述系统链码3用于在执行时获取正在执行的交易的交易提案。
在一种实施方式中,如上文所述,链码1例如为跨链转账链码,链码2例如为用于发送跨链消息的链码,链码1通过调用链码2,而将跨链转账的消息发送给链外。当用户设备12对应的用户1希望对另一个区块链(或该Fabric区块链的另一个通道)中的用户2进行转账时,用户1通过用户设备12生成交易1的交易提案,在该交易提案中调用链码1,对该链码1传入待转出本通道的金额数、接收转账的区块链和区块链账户(即用户2账户)作为传入参数。链码1中调用链码2,以用于向通道11的账本数据库中存入链码1的名称、所述金额、接收转账的区块链标识和区块链账户,以向链外发送该消息。链码2中预先写入了系统链码3的系统调用接口GetSignedProposal,从而链码2在被预执行时可通过该调用接口预执行系统链码3,从而获取由用户1发出的经用户1签名的交易提案,从中获取链码1的名称,并基于链码1的名称生成上述向链外发送的 消息。
可以理解,在该实施方式中,在通道11中不限于仅由链码1调用链码2以向链外发送消息。如上文所述,通道11中可能包括多个客户链码,链码2为第三方服务链码,各个客户链码都可以调用链码2,以使用该链码提供的跨链发送消息的服务。
在一种实施方式中,所述链码2不限于为用于跨链业务的链码,其也可以为用于通道11内的业务的链码。例如,链码1为用于进行人民币-美元兑换的链码,链码1的账户状态中记录了各个用户的人民币账户余额,链码2为用于进行美元-人民币兑换的链码,链码2的账户状态中记录了各个用户的美元账户余额。在该实施方式中,当用户1希望进行将其人民币账户中的预定金额兑换成美元时,其生成交易1的交易提案,其中,在该交易提案中调用链码1,以将要兑换的人民币金额作为该链码1的传入参数。同样地,链码2中通过写入系统接口GetSignedProposal以调用系统链码3,从而链码2在预执行时可通过预执行系统链码3获取调用其的链码的名称,并确定该名称是否为链码1的名称,如果是链码1的名称,则可以继续执行,如果不是,则结束执行。也就是说,在该实施方式中,为了保证资金兑换的安全性,链码2只允许由链码1对其进行调用,链码2在执行时需要获取调用其链码的名称以判断该链码是否为链码1,从而,链码2通过调用系统链码3来获取调用其的链码的名称。
用户设备12在生成交易1的交易提案之后,使用其通道11的区块链账户的私钥对该交易提案进行签名。
在步骤S204,向节点设备2发送交易1的交易提案。
用户设备12在生成交易1的交易提案之后,可将该交易提案发送给至少一个背书节点(即背书节点的节点设备),例如,用户设备12向图1中的节点设备2发送交易1的交易提案。具体是,用户设备12在生成交易1的交易提案及其签名之后,将交易提案及其签名发送给至少一个背书节点。
图3示出根据本说明书实施例的一种在Fabric区块链中预执行链码的方法流程图,所述Fabric区块链中包括作为客户端节点的用户设备12和作为背书节点的节点设备2,所述方法由节点设备2执行,包括:步骤S302,从用户设备12接收交易1的交易提案,所述交易提案中包括对链码1的调用,所述链码1中包括对链码2的调用,所述链码2中包括对系统链码3的调用;
步骤S304,在开始预执行交易1中的链码2之后,通过预执行系统链码3,获取交 易1的交易提案;步骤S306,从所述交易提案中获取所述链码1的名称;步骤S308,基于链码1的名称进行相应的处理。
如上文所述,在Fabric区块链中,包括对交易的预执行过程和对交易的提交过程,在预执行过程中,由背书节点对交易进行预执行,获取预执行的读写集,但是并不将该读写集存入账本数据中,在提交过程中,基于交易顺序对各个交易的预执行进行验证,在验证通过的情况中,标记该交易有效,并将交易的交易提案、读写集和交易执行状态(即交易是否有效)存入账本数据中。因此,在Fabric区块链中,对交易的预执行过程也即为对交易的执行过程。
首先,在步骤S302,从用户设备12接收交易1的交易提案,所述交易提案中包括对链码1的调用,所述链码1中包括对链码2的调用,所述链码2中包括对系统链码3的调用。
在该步骤中,对交易1的具体描述可参考上文对步骤S202的描述,在此不再赘述。节点设备2除了从用户设备12接收交易1的交易提案之外,还接收用户设备12对该交易提案的签名。
步骤S304,在开始预执行交易1中的链码2之后,通过预执行系统链码3,获取交易1的交易提案。
在预执行所述交易1之前,节点设备2可使用用户设备12对应的公钥对接收的交易提案的签名进行验证,以验证该交易提案是否由用户设备12发出,该交易提案的内容是否经过篡改。
节点设备2作为背书节点在从用户设备12接收到交易1的交易提案并对其签名验证通过之后,执行相对于背书节点预设的对交易提案的处理过程,即预执行交易1,生成预执行交易1的读写集,对读写集进行签名,并将读写集和签名发送回用户设备12。
其中,如图1所示,在预执行交易1的过程中,包括预执行其中调用的链码1。如上文所述,在一种实施方式中,链码1例如为跨链转账链码,对链码1的传入参数包括待转出本通道的金额数、接收转账的区块链和区块链账户。在预执行链码1的过程中,首先读取用户设备12对应的用户1的账户余额,在预执行交易1的读集记录该读取的账户余额,对用户1的账户余额减少所述金额数,并在预执行交易1的写集中记录对用户1的账户余额的更改,然后,通过链码1中对链码2的调用,执行链码2以向链外发送转账消息。链码2例如为用于发送跨链消息的链码。其不限于被链码1调用,而可以 被通道11中的多种链码进行调用。在该情况中,在跨链消息中需要标明,链码2是被通道11中的哪个链码进行调用的,不同的链码对应于链外的不同的处理过程,例如,对于链码1,在链外预设了有对应的转账处理,因此,只有确定了调用链码2的链码名称的情况中,才可以进行对该跨链消息的正确的后续的处理。在本说明书实施例中,通过在链码2中预先写入调用系统链码3的调用接口GetSignedProposal,从而对系统链码3进行调用。系统链码3用于在执行时获取正在执行的交易的交易提案。从而,在开始执行链码2之后,执行其中调用的系统链码3,从而获取经签名的交易1的交易提案。
在一种实施方式中,链码1例如为用于进行人民币-美元兑换的链码,链码2为用于进行美元-人民币兑换的链码,链码2只允许由链码1对其进行调用。因此,在预执行交易1的过程中,首先通过预执行链码1,读取用户1的人民币账户余额,在预执行交易1的读集中记录该读取的账户余额,对该账户余额减少需要兑换的金额,并在预执行交易1的写集中记录对应用户1的人民币账户余额的更改,然后通过链码1对链码2的调用,预执行链码2以更改用户1的美元账户。在开始预执行链码2之后,需要确定调用其的链码是否为链码1,以用于确定是否结束对交易1的预执行。从而,通过预执行链码2中调用的系统链码3,获取经签名的交易1的交易提案。
在步骤S306,从所述交易提案中获取所述链码1的名称。
在获取交易1的交易提案之后,由于交易提案中包括链码1的调用,因此,可基于该对链码1的调用获取链码1的名称。
在步骤S308,基于链码1的名称进行相应的处理。
在一种实施方式中,链码1例如为跨链转账链码,链码2例如为用于发送跨链消息的链码。在节点设备2中,在通过预执行系统链码3获取链码1的名称之后,在预执行交易1的读集或写集中记录:链码1的名称、转出本通道的金额数、接收转账的区块链和区块链账户,并在预执行完成之后,对获取的读写集进行签名。用户设备12在从节点设备2接收到经签名的预执行交易1的读写集之后,对交易1的交易内容进行广播,该交易内容中包括交易1的交易提案和预执行读写集。之后,如前文所述,经过通道11中各个节点的操作,最终将交易1的交易提案和预执行读写集作为账本数据存储到各个提交节点的节点设备中。从而,链下设备通过在通道11中查询交易1的内容,可获取交易1的读写集,然后基于其中记录的链码1的名称,进行与链码1相对应的跨链转账处理。
在一种实施方式中,链码1例如为用于进行人民币-美元兑换的链码,链码2为用于进行美元-人民币兑换的链码,链码2只允许由链码1对其进行调用。因此,当在预执行系统链码3并获取链码1的名称之后,确定该名称是否为链码1的名称,如果是,则继续预执行交易1,即更改用户1的美元账户余额,并在读写集中进行记录,如果不是,则在预执行的写集中记录兑换失败,结束对交易1的预执行。
图4示出根据本说明书实施例的一种在Fabric区块链中调用链码的装置400,所述Fabric区块链中包括客户端节点和背书节点,所述装置400部署于所述客户端节点,包括:生成单元41,配置为,生成第一交易的交易提案,所述交易提案中包括对所述第一链码的调用,所述第一链码中包括对第二链码的调用,所述第二链码中包括对预定系统链码的调用,所述预定系统链码用于在执行时获取正在执行的交易的交易提案;发送单元42,配置为,向所述背书节点发送所述第一交易的交易提案。
在一种实施方式中,所述装置400还包括,签名单元43,配置为,在生成第一交易的交易提案之后,生成对所述交易提案的签名,其中,所述发送单元42还配置为,向所述背书节点发送所述第一交易的交易提案和所述签名。
图5示出根据本说明书实施例的一种在Fabric区块链中预执行链码的装置500,所述Fabric区块链中包括客户端节点和背书节点,所述装置500部署于所述背书节点,包括:接收单元51,配置为,从客户端节点接收第一交易的交易提案,所述交易提案中包括对第一链码的调用,所述第一链码中包括对第二链码的调用,所述第二链码中包括对预定系统链码的调用;第一获取单元52,配置为,在开始预执行所述第一交易中的第二链码之后,通过预执行所述预定系统链码,获取所述第一交易的交易提案;第二获取单元53,配置为,从所述交易提案中获取所述第一链码的名称;处理单元54,配置为,基于所述第一链码的名称进行相应的处理。
在一种实施方式中,所述第二链码仅用于被预定链码调用,其中,所述处理单元54还配置为,判断所述第一链码是否为所述预定链码,基于所述判断的结果确定是否结束对所述第二链码的预执行。
在一种实施方式中,所述处理单元54还配置为,将所述第一链码的名称写入所述交易的读集或写集中。
在一种实施方式中,所述接收单元51还配置为,从客户端节点接收第一交易的交易提案和所述客户端节点对所述交易提案的签名,所述装置500还包括,验证单元55,配 置为,对所述签名进行验证。
本说明书另一方面提供一种计算机可读存储介质,其上存储有计算机程序或指令,当所述计算机程序或指令在计算机中执行时,令计算机执行上述任一种方法。
本说明书另一方面提供一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序或指令,所述处理器在执行所述计算机程序或指令时,实现上述任一种方法。
通过根据本说明书实施例的调用和执行链码的方案,通过在被调用链码中写入系统链码接口GetSignedProposal进行系统链码调用,获取原始提案的内容,并从中提取起始调用的链码的名称,从而识别调用方链码的身份,以便于基于该调用方链码的名称进行后续处理。
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。
本领域普通技术人员应该还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。本领域普通技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
结合本文中所公开的实施例描述的方法或算法的步骤可以用硬件、处理器执行的软件模块,或者二者的结合来实施。软件模块可以置于随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存器、硬盘、可移动磁盘、CD-ROM、或技术领域内所公知的任意其它形式的存储介质中。
以上所述的具体实施方式,对本说明书实施例的目的、技术方案和有益效果进行了 进一步详细说明,所应理解的是,以上所述仅为本说明书实施例的具体实施方式而已,并不用于限定本说明书实施例的保护范围,凡在本说明书实施例的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本说明书实施例的保护范围之内。

Claims (16)

  1. 一种在Fabric区块链中调用链码的方法,所述Fabric区块链中包括客户端节点和背书节点,所述方法由所述客户端节点执行,包括:
    生成第一交易的交易提案,所述交易提案中包括对所述第一链码的调用,所述第一链码中包括对第二链码的调用,所述第二链码中包括对预定系统链码的调用,所述预定系统链码用于在执行时获取正在执行的交易的交易提案;
    向所述背书节点发送所述第一交易的交易提案。
  2. 根据权利要求1所述的方法,还包括,在生成第一交易的交易提案之后,生成对所述交易提案的签名,其中,向所述背书节点发送所述第一交易的交易提案包括,向所述背书节点发送所述第一交易的交易提案和所述签名。
  3. 一种在Fabric区块链中预执行链码的方法,所述Fabric区块链中包括客户端节点和背书节点,所述方法由所述背书节点执行,包括:
    从客户端节点接收第一交易的交易提案,所述交易提案中包括对第一链码的调用,所述第一链码中包括对第二链码的调用,所述第二链码中包括对预定系统链码的调用;
    在开始预执行所述第一交易中的第二链码之后,通过预执行所述预定系统链码,获取所述第一交易的交易提案;
    从所述交易提案中获取所述第一链码的名称;
    基于所述第一链码的名称进行相应的处理。
  4. 根据权利要求3所述的方法,其中,所述第二链码仅用于被预定链码调用,其中,基于所述第一链码的名称进行相应的处理包括,判断所述第一链码是否为所述预定链码,基于所述判断的结果确定是否结束对所述第二链码的预执行。
  5. 根据权利要求3所述的方法,其中,基于所述第一链码的名称进行相应的处理包括,将所述第一链码的名称写入所述交易的读集或写集中。
  6. 根据权利要求5所述的方法,其中,所述第二链码为用于发送跨链消息的链码。
  7. 根据权利要求3所述的方法,其中,从客户端节点接收第一交易的交易提案包括,从客户端节点接收第一交易的交易提案和所述客户端节点对所述交易提案的签名,所述方法还包括,对所述签名进行验证。
  8. 一种在Fabric区块链中调用链码的装置,所述Fabric区块链中包括客户端节点和背书节点,所述装置部署于所述客户端节点,包括:
    生成单元,配置为,生成第一交易的交易提案,所述交易提案中包括对所述第一链码的调用,所述第一链码中包括对第二链码的调用,所述第二链码中包括对预定系统链 码的调用,所述预定系统链码用于在执行时获取正在执行的交易的交易提案;
    发送单元,配置为,向所述背书节点发送所述第一交易的交易提案。
  9. 根据权利要求8所述的装置,还包括,签名单元,配置为,在生成第一交易的交易提案之后,生成对所述交易提案的签名,其中,所述发送单元还配置为,向所述背书节点发送所述第一交易的交易提案和所述签名。
  10. 一种在Fabric区块链中预执行链码的装置,所述Fabric区块链中包括客户端节点和背书节点,所述装置部署于所述背书节点,包括:
    接收单元,配置为,从客户端节点接收第一交易的交易提案,所述交易提案中包括对第一链码的调用,所述第一链码中包括对第二链码的调用,所述第二链码中包括对预定系统链码的调用;
    第一获取单元,配置为,在开始预执行所述第一交易中的第二链码之后,通过预执行所述预定系统链码,获取所述第一交易的交易提案;
    第二获取单元,配置为,从所述交易提案中获取所述第一链码的名称;
    处理单元,配置为,基于所述第一链码的名称进行相应的处理。
  11. 根据权利要求10所述的装置,其中,所述第二链码仅用于被预定链码调用,其中,所述处理单元还配置为,判断所述第一链码是否为所述预定链码,基于所述判断的结果确定是否结束对所述第二链码的预执行。
  12. 根据权利要求10所述的装置,其中,所述处理单元还配置为,将所述第一链码的名称写入所述交易的读集或写集中。
  13. 根据权利要求12所述的装置,其中,所述第二链码为用于发送跨链消息的链码。
  14. 根据权利要求10所述的装置,其中,所述接收单元还配置为,从客户端节点接收第一交易的交易提案和所述客户端节点对所述交易提案的签名,所述装置还包括,验证单元,配置为,对所述签名进行验证。
  15. 一种计算机可读存储介质,其上存储有计算机程序或指令,当所述计算机程序或指令在计算机中执行时,令计算机执行权利要求1-7中任一项的所述的方法。
  16. 一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序或指令,所述处理器在执行所述计算机程序或指令时,实现权利要求1-7中任一项所述的方法。
PCT/CN2022/081722 2021-03-30 2022-03-18 一种在Fabric区块链中预执行链码的方法和装置 WO2022206433A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110339805.9A CN112734410B (zh) 2021-03-30 2021-03-30 一种在Fabric区块链中预执行链码的方法和装置
CN202110339805.9 2021-03-30

Publications (1)

Publication Number Publication Date
WO2022206433A1 true WO2022206433A1 (zh) 2022-10-06

Family

ID=75596188

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/081722 WO2022206433A1 (zh) 2021-03-30 2022-03-18 一种在Fabric区块链中预执行链码的方法和装置

Country Status (2)

Country Link
CN (1) CN112734410B (zh)
WO (1) WO2022206433A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112734410B (zh) * 2021-03-30 2021-07-06 支付宝(杭州)信息技术有限公司 一种在Fabric区块链中预执行链码的方法和装置
CN113672305A (zh) * 2021-09-03 2021-11-19 中国银行股份有限公司 一种链码启动方法、装置、设备和可读存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140214772A1 (en) * 2013-01-28 2014-07-31 Netapp, Inc. Coalescing Metadata for Mirroring to a Remote Storage Node in a Cluster Storage System
CN111163165A (zh) * 2019-12-28 2020-05-15 北京工业大学 一种基于Fabric联盟链的投票共识方法
CN111191286A (zh) * 2019-12-28 2020-05-22 南京理工大学 Hyperledger Fabric区块链隐私数据存储与访问系统及其方法
CN112734410A (zh) * 2021-03-30 2021-04-30 支付宝(杭州)信息技术有限公司 一种在Fabric区块链中预执行链码的方法和装置

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110033244B (zh) * 2019-03-15 2021-10-22 创新先进技术有限公司 基于区块链的智能合约执行方法及装置和电子设备
CN110197085B (zh) * 2019-06-14 2022-12-09 福州大学 一种基于fabric联盟链的文档防篡改方法
CN110310205B (zh) * 2019-06-28 2022-02-25 百度在线网络技术(北京)有限公司 一种区块链数据监控方法、装置、设备和介质
CN110503433B (zh) * 2019-08-28 2022-05-10 北京百度网讯科技有限公司 一种区块链中背书的实现方法、装置、设备和介质
CN111931236B (zh) * 2020-08-19 2024-01-16 广州大学 一种数据通信监控方法、系统及计算机可读存储介质

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140214772A1 (en) * 2013-01-28 2014-07-31 Netapp, Inc. Coalescing Metadata for Mirroring to a Remote Storage Node in a Cluster Storage System
CN111163165A (zh) * 2019-12-28 2020-05-15 北京工业大学 一种基于Fabric联盟链的投票共识方法
CN111191286A (zh) * 2019-12-28 2020-05-22 南京理工大学 Hyperledger Fabric区块链隐私数据存储与访问系统及其方法
CN112734410A (zh) * 2021-03-30 2021-04-30 支付宝(杭州)信息技术有限公司 一种在Fabric区块链中预执行链码的方法和装置

Also Published As

Publication number Publication date
CN112734410B (zh) 2021-07-06
CN112734410A (zh) 2021-04-30

Similar Documents

Publication Publication Date Title
US11138608B2 (en) Authorizing multiparty blockchain transactions via one-time passwords
EP3507938B1 (en) Biometric identification and verification among iot devices and applications
US20200076615A1 (en) Trusted identity solution using blockchain
WO2020073491A1 (zh) 基于区块链的供应链支付方法、收款方法、装置、设备及介质
US20180054436A1 (en) Server based biometric authentication
WO2022206433A1 (zh) 一种在Fabric区块链中预执行链码的方法和装置
TWI709925B (zh) 業務處理的方法和裝置
CN109146679A (zh) 基于区块链的智能合约调用方法及装置、电子设备
US11909728B2 (en) Network resource access control methods and systems using transactional artifacts
CN110535648A (zh) 电子凭证生成及验证和密钥控制方法、装置、系统和介质
EP3933624B1 (en) Blockchain-based identity verification method and related hardware
WO2022206454A1 (zh) 提供跨链消息的方法和装置
WO2020160391A1 (en) An efficient, environmental and consumer friendly consensus method for cryptographic transactions
CN112488682B (zh) 一种区块链的三方转账方法及装置
CN112560072A (zh) 基于区块链的密钥管理方法、装置、介质及设备
WO2018210097A1 (zh) 交易模式的分类执行方法及装置
CN113328854B (zh) 基于区块链的业务处理方法及系统
CN113205342A (zh) 基于多端支付的用户身份验证方法及装置
CN115526629A (zh) 基于区块链网络的收单交易方法、装置及身份认证装置
WO2021121030A1 (zh) 一种资源转移的方法及结账终端、服务器节点
CN112861184A (zh) 资产证明的验证与生成方法、装置及电子设备
CN115375303A (zh) 智能合约的调用方法、装置、计算机可读介质及电子设备
CN114139121A (zh) 身份验证方法、装置、电子设备及计算机可读存储介质
CN106534047A (zh) 一种基于Trust应用的信息传输方法及装置
CN111027992A (zh) 基于区块链系统的资产交易方法、装置及硬件设备

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: 22778616

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 22778616

Country of ref document: EP

Kind code of ref document: A1