CPC G06F 16/2379 (2019.01) [G06F 9/45558 (2013.01); G06F 2009/4557 (2013.01)] | 17 Claims |
1. A method for parallel execution of a smart contract, wherein the smart contract comprises an annotation for a cross-contract calling, the method specifically comprises the following steps:
loading a smart contract in a first transaction, obtaining the annotation for the cross-contract calling in the smart contract in the first transaction by reflection, obtaining an address for the cross-contract calling corresponding to the annotation for the cross-contract calling and loading a smart contract corresponding to the address for the cross-contract calling, and obtaining, by recursion, a chain table for a cross-contract calling starting with an address of the contract called in the first transaction;
determining, according to the chain table for the cross-contract calling of each transaction in target execution transactions and contract types of smart contracts in the target execution transactions, a calling dependency relationship of the transactions, and obtaining, according to the calling dependency relationship, transaction calling chains that do not affect each other during an execution process, wherein the target execution transactions comprise the first transaction, and the contract types comprise a calling contract and a deployment contract; and
executing the transaction calling chains in parallel in instances of virtual machines, each of the instances of the virtual machines executing a transaction calling chain and returning an execution result.
|