Smart contract debugging method and device, storage medium and electronic equipment

The method and device facilitate parallel and efficient smart contract debugging through a dedicated blockchain instance and WebSocket protocol, addressing inefficiencies in existing JavaScript-based debugging by isolating instances and supporting parallel execution.

CN119105843APending Publication Date: 2024-12-10BUBI (BEIJING) NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411317399.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-20
Publication Date
2024-12-10

AI Technical Summary

Technical Problem

Current smart contract debugging methods, particularly for JavaScript-based smart contract virtual machines, lack parallel debugging capabilities and are inefficient, leading to prolonged debugging times.

Method used

A method and device that utilize a dedicated blockchain instance for each user, employing the WebSocket protocol to deploy and debug smart contracts, allowing for parallel debugging and efficient code execution, with modules for initialization, deployment, triggering, and reading to enhance debugging efficiency.

Benefits of technology

Enables parallel and efficient debugging of smart contracts, improving debugging speed and efficiency by isolating instances and supporting JavaScript language debugging, thereby reducing overall debugging time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119105843A_ABST
    Figure CN119105843A_ABST
Patent Text Reader

Abstract

The invention relates to a smart contract debugging method and device, a storage medium and electronic equipment. The method comprises the following steps: receiving a to-be-debugged smart contract, and initializing a block chain network to obtain an initialized block chain which is dedicated to debugging and comprises a smart contract virtual machine; based on a webpage socket protocol, deploying a to-be-debugged smart contract on the initialized block chain, and initializing a smart contract virtual machine to perform code debugging; encapsulating the transaction request based on a webpage socket protocol, and driving the smart contract virtual machine to run the smart contract to be debugged according to the transaction request so as to perform function debugging; reading a debugging result of debugging the to-be-debugged smart contract, and adjusting a smart contract code corresponding to the to-be-debugged smart contract according to the debugging result and a preset scene result corresponding to the to-be-debugged smart contract; and performing re-debugging according to the adjusted smart contract code, confirming that the debugging of the to-be-debugged smart contract is finished, and releasing the initialized block chain. The debugging efficiency of the smart contract can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain technology, and in particular to a smart contract debugging method, device, storage medium and electronic device. Background Art

[0002] Blockchain is a decentralized distributed ledger technology that uses cryptography to achieve functions such as information addressing, verification, storage and transaction through a peer-to-peer blockchain network. With its decentralization, transparency, traceability and tamper-proof characteristics, it is widely used in smart contract transactions including encrypted asset transactions.

[0003] In blockchain, smart contracts are a key component of blockchain, providing programmability for blockchain. Developers write business logic code based on smart contracts and upload the written smart contract code to the blockchain to run, so as to ensure the transparency and immutability of the business logic corresponding to the smart contract.

[0004] The operation of smart contracts in blockchain mainly depends on smart contract virtual machines, which are used to provide the operating environment of smart contract codes, realize the functions of external data input, data processing, and writing the execution results of data processing into the account database. At present, smart contract virtual machines include: Ethereum (EVM, Ethereum Virtual Machine) virtual machine, JsVM (Javascript Virtual Machine) virtual machine and web browser assembly (WASM, WebAssembly Virtual Machine) virtual machine. Among them, EVM virtual machine is the virtual machine of Ethereum chain, which supports solidity language to write smart contract code, JsVM virtual machine is mainly based on Google Chrome's V8 implementation, supports JavaScript language to write smart contracts, and WASM virtual machine supports C / C++ language to write smart contracts.

[0005] For smart contract virtual machines, smart contract debugging is required before the online smart contract code runs, so that developers can find problems in the smart contract code during operation, and adjust the smart contract code to quickly write accurate smart contract code to ensure the normal operation of the smart contract virtual machine. In the related technology, for smart contract debugging of EVM virtual machines, developers can use the remix debugging tool to implement the debugging function that supports the Solidity programming language; for JsVM virtual machine debugging, Chrome V8 only supports single-step debugging, which makes the current smart contract debugging method unable to support JavaScript language debugging, and can only serially debug the smart contracts created on the blockchain, and cannot debug smart contracts in parallel, resulting in a long time required for smart contract debugging and low debugging efficiency. Summary of the invention

[0006] In view of this, the present invention provides a smart contract debugging method, device, storage medium and electronic device.

[0007] Specifically, the present invention is achieved through the following technical solutions:

[0008] According to a first aspect of the present invention, a method for debugging a smart contract is provided, and the method for debugging a smart contract comprises:

[0009] Receive a smart contract to be debugged, initialize a blockchain network to obtain an initialized blockchain dedicated to debugging the smart contract to be debugged, and the initialized blockchain includes a smart contract virtual machine;

[0010] Based on the web socket protocol, deploy the smart contract to be debugged on the initialized blockchain, and initialize the smart contract virtual machine on which the smart contract to be debugged is deployed to perform code debugging on the smart contract to be debugged;

[0011] Encapsulating a transaction request set for the smart contract to be debugged based on the web socket protocol, and driving the initialized smart contract virtual machine to run the smart contract to be debugged according to the transaction request, so as to perform functional debugging on the smart contract to be debugged;

[0012] Reading a debugging result of debugging the smart contract to be debugged, and adjusting the smart contract code corresponding to the smart contract to be debugged according to the debugging result and a preset scenario result corresponding to the smart contract to be debugged;

[0013] Re-debugging is performed according to the adjusted smart contract code, and debugging of the smart contract to be debugged is confirmed to be completed, and the initialized blockchain is released.

[0014] The smart contract debugging method in this technical solution is based on the smart contract debugging of each user, and a new dedicated blockchain instance is opened, so that each opened blockchain instance is isolated from each other and does not affect each other, and the smart contract debugging based on the JavaScript language is realized, which can effectively improve the debugging efficiency.

[0015] According to a second aspect of the present invention, a debugging device for a smart contract is provided, and the debugging device for a smart contract comprises:

[0016] A blockchain initialization module, used to receive a smart contract to be debugged, initialize a blockchain network to obtain an initialized blockchain dedicated to debugging the smart contract to be debugged, wherein the initialized blockchain includes a smart contract virtual machine;

[0017] A smart contract deployment module, used to deploy the smart contract to be debugged on the initialized blockchain based on the web socket protocol, initialize the smart contract virtual machine for deploying the smart contract to be debugged, so as to perform code debugging on the smart contract to be debugged;

[0018] A smart contract triggering module, used to encapsulate a transaction request set for the smart contract to be debugged based on the web socket protocol, and drive the initialized smart contract virtual machine to run the smart contract to be debugged according to the transaction request, so as to perform functional debugging on the smart contract to be debugged;

[0019] A smart contract reading module, used to read the debugging result of the smart contract to be debugged, and adjust the smart contract code corresponding to the smart contract to be debugged according to the debugging result and the preset scenario result corresponding to the smart contract to be debugged;

[0020] The blockchain release module is used to re-debug according to the adjusted smart contract code, confirm that the debugging of the smart contract to be debugged is completed, and release the initialized blockchain.

[0021] According to a third aspect of the present invention, there is provided a storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method for debugging a smart contract in any possible implementation of the first aspect.

[0022] According to a fourth aspect of the present invention, there is provided an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the method for debugging a smart contract in any possible implementation of the first aspect are implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0024] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0025] Figure 1 A flowchart of a smart contract debugging method provided by an embodiment of the present invention;

[0026] Figure 2 A schematic diagram of a process of S10 in a smart contract debugging method provided by an embodiment of the present invention;

[0027] Figure 3 A schematic diagram of a process of S20 in a smart contract debugging method provided by an embodiment of the present invention;

[0028] Figure 4 A schematic diagram of a process of S30 in a smart contract debugging method provided by an embodiment of the present invention;

[0029] Figure 5 A schematic diagram of a process of S40 in a smart contract debugging method provided by an embodiment of the present invention;

[0030] Figure 6 A schematic diagram of a process of S50 in a smart contract debugging method provided by an embodiment of the present invention;

[0031] Figure 7 A schematic diagram of a smart contract debugging device provided by an embodiment of the present invention;

[0032] Figure 8 A schematic diagram of a smart contract debugging system provided by an embodiment of the present invention;

[0033] Fig. 9 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0034] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0035] See also Figure 1, an embodiment of the present invention provides a smart contract debugging method, which may include the following steps:

[0036] S10, receiving a smart contract to be debugged, initializing a blockchain network to obtain an initialized blockchain dedicated to debugging the smart contract to be debugged, wherein the initialized blockchain includes a smart contract virtual machine;

[0037] In this embodiment, the smart contract to be debugged is obtained by editing the JavaScript language. When debugging of the smart contract is required, the smart contract to be debugged is input through the debugging front end, and the blockchain is initialized to obtain the initialization blockchain, which is used to debug the smart contract to be debugged submitted by the user and is independently occupied and used by the user who submitted the smart contract to be debugged. In this way, the initialization blockchains used to debug each smart contract are isolated from each other and do not affect each other, and debugging can be performed in parallel in the blockchain network, thereby improving the debugging efficiency of smart contracts.

[0038] Figure 2 A flowchart of S10 in a smart contract debugging method provided in an embodiment of the present invention. In this embodiment, as an optional embodiment, the method includes:

[0039] S101, after the debugging front end establishes a connection with the debugging back end through the HTTP protocol, it sends a web socket connection request to the debugging back end to obtain the web socket address and page service code of the debugging back end;

[0040] In this embodiment, the user starts the debugging front end. After the debugging front end and the debugging back end establish an HTTP connection through the HTTP protocol, a web socket connection request carrying the web socket address and page service code of the debugging front end is sent to the debugging back end, and the web socket (websocket) debugging back end address (web socket address) and page service code for debugging are obtained from the debugging back end. Among them, the web socket address is used for the debugging front end to establish a web socket connection with the debugging back end, and the page service code is used to set the display interface of the debugging front end, so as to present the running interface of the debugging back end during the debugging process of the smart contract to be debugged on the debugging front end.

[0041] S102, the debugging front end establishes a web socket connection with the debugging back end based on the acquired web socket address of the debugging back end;

[0042] In this embodiment, the debugging front end establishes a websocket connection with the debugging back end based on the websocket debugging back end address used for debugging.

[0043] S103, the debugging front end sends a blockchain initialization request carrying request parameters to the debugging back end according to the received smart contract to be debugged, so that the debugging back end creates an initialized blockchain according to the received blockchain initialization request;

[0044] In this embodiment, as an optional embodiment, the debugging backend creates an initialization blockchain according to the received blockchain initialization request, including:

[0045] After the debugging backend establishes a websocket connection with the debugging frontend, a new blockchain including the intelligent virtual machine is created and the newly created blockchain is initialized according to the request parameters transmitted by the debugging frontend to form an initialized blockchain.

[0046] In this embodiment, as another optional embodiment, the debugging backend creates an initialization blockchain according to the received blockchain initialization request, including:

[0047] Based on the latest created blockchain, under the latest created blockchain, a forked chain including an intelligent virtual machine is newly created and the forked chain is initialized to form an initialized blockchain.

[0048] In this embodiment, it is set in the blockchain network that a new blockchain (initialized blockchain) is generated only when the user submits the smart contract code corresponding to the smart contract to be debugged.

[0049] S104, obtaining the blockchain information of the newly created initialized blockchain through the debugging front end;

[0050] In this embodiment, the user obtains the blockchain information of the newly created initialized blockchain through the debugging front end. As an optional embodiment, the blockchain information includes but is not limited to: the genesis account private key, the genesis account address, and the genesis block hash value. Among them, the genesis account private key and the genesis account address are used to debug the smart contract for the new account, and the genesis block hash value is used to identify the newly created blockchain for subsequent query and use.

[0051] S105, through the debugging front end, a new blockchain account for debugging the smart contract to be debugged is created in the initialized blockchain based on the blockchain information.

[0052] In this embodiment, the debugging front end is used to create multiple new blockchain accounts through the initial account. For example, if the smart contract to be debugged contains multiple transaction functions, multiple new blockchain accounts for blockchain transactions are created. For example, 5 new blockchain accounts are created for subsequent debugging.

[0053] S20, deploying the smart contract to be debugged on the initialized blockchain based on the web socket protocol, and initializing the smart contract virtual machine on which the smart contract to be debugged is deployed, so as to perform code debugging on the smart contract to be debugged;

[0054] In this embodiment, after the user has written the smart contract code corresponding to the smart contract to be debugged, the smart contract code is deployed on the initialized blockchain through the pre-set blockchain interface using the web socket protocol. After the deployment is successful, the smart contract code can be debugged.

[0055] Figure 3 A flowchart of S20 in a smart contract debugging method provided in an embodiment of the present invention. In this embodiment, as an optional embodiment, the method includes:

[0056] S201, sending a request to start debugging and deploying a contract to the debugging backend through the debugging frontend;

[0057] In this embodiment, the debugging front end initiates a request to start debugging and deploying a contract to the debugging back end. As an optional embodiment, the request to start debugging and deploying a contract includes contract deployment information. As an optional embodiment, the contract deployment information includes but is not limited to: the debugging type is a deployed contract, the source (initiating) account address, the smart contract code, the smart contract initialization parameters and the signature information. Among them, the debugging type matches the debugging instruction, including but not limited to: deploying the smart contract code to be debugged, executing the smart contract to be debugged, starting debugging, resuming operation, stepping over, and stepping into.

[0058] In this embodiment, as an optional embodiment, an example of starting a debugging deployment contract request is as follows:

[0059] Tx=<<CREATE_CONTRACT,SourceAddress,ContractCode,InitInput> , Signature>, where:

[0060] CREATE_CONTRACT: This transaction is a contract deployment transaction (deployment of the smart contract code to be debugged);

[0061] SourceAddress: the account address that initiated the transaction;

[0062] ContractCode: smart contract code;

[0063] InitInput: smart contract initialization parameters;

[0064] Signature:<CREATE_CONTRACT,SourceAddress,ContractCode,InitInput> The signature information of these four data includes the deployment contract transaction, the initiating account address, the smart contract code and the smart contract initialization parameters.

[0065] S202, the debugging backend verifies the received request to start debugging and deploying the contract;

[0066] In this embodiment, after receiving the request to start debugging and deploying a contract, the debugging backend starts a thread to process the request to start debugging and deploying a contract.

[0067] In this embodiment, as an optional embodiment, the step includes:

[0068] Calling the blockchain account book, obtaining the transaction format corresponding to the start debugging and deployment contract request, and verifying the validity of the start debugging and deployment contract request;

[0069] After the validity verification is passed, the blockchain account book is called to store the smart contract code carried in the start debugging and deployment contract request.

[0070] S203, after the verification is passed, the debugging backend calls the debugging agent to initialize the smart contract virtual machine according to the smart contract initialization parameters carried in the start debugging and deploying contract request, and returns a start debugging and deploying contract request response to the debugging frontend;

[0071] In this embodiment, the debugging backend calls the JavaScript smart contract virtual machine, and initializes the virtual machine parameters to run the smart contract code according to the smart contract initialization parameters carried in the start debugging deployment contract request.

[0072] In this embodiment, the validity of the data carried in the request to start debugging and deploying the contract is verified according to the data format (transaction format) corresponding to the smart contract code to be debugged; then the blockchain account interface is called to store the smart contract information (smart contract code) of the transaction; finally, the JavaScript smart contract virtual machine is called, and the virtual machine parameters of the JavaScript smart contract virtual machine are initialized according to the smart contract initialization parameters in the request to prepare to run the smart contract code.

[0073] In this embodiment, as an optional embodiment, the smart contract virtual machine includes but is not limited to a JavaScript smart contract virtual machine. After the debugging backend verifies the start debugging deployment contract request, it calls the debugging agent to start the smart contract virtual machine, and initializes the smart contract virtual machine according to the smart contract initialization parameters carried in the debugging deployment contract request. After completing the initialization of the smart contract virtual machine, it suspends operation, returns a start debugging deployment contract request response indicating that the smart contract virtual machine debugging work is ready to the debugging front end, and waits for the debugging instruction of the debugging front end.

[0074] S204, the debugging front end responds to the received request to start debugging and deploying the contract, and after confirming that the debugging back end has been initialized, sends a parameter setting request for monitoring the operation of the smart contract to be debugged to the debugging back end;

[0075] In this embodiment, after confirming that the debugging work of the smart contract virtual machine is ready, the debugging front end sends a parameter setting request to the debugging back end so that the debugging back end sets the relevant parameters for debugging the smart contract virtual machine.

[0076] In this embodiment, as an optional embodiment, the parameters included in the parameter setting request are: starting the debugger (smart contract virtual machine) parameters, pausing the program parameters when an exception occurs during debugging, setting the asynchronous call stack depth parameters, and starting the running performance statistics parameters, so as to configure the smart contract virtual machine accordingly.

[0077] S205, the debugging backend calls the debugging agent to set the parameters carried in the parameter setting request in the smart contract virtual machine according to the received parameter setting request, and returns a parameter setting request response carrying the parameter setting result to the debugging front end.

[0078] In this embodiment, after the debugging agent sets the corresponding relevant parameters in the smart contract virtual machine according to the parameter setting request, the smart contract virtual machine intercepts the corresponding information according to the parameters carried in the parameter setting request during the running of the smart contract to be debugged, and returns the result after setting the parameters to the debugging front end through the debugging back end.

[0079] In this embodiment, as an optional embodiment, the method further includes:

[0080] The debugging agent returns the parameter setting request response to the smart contract virtual machine, so that the smart contract virtual machine runs the smart contract code to be debugged and pauses at the first line of executable code.

[0081] In this embodiment, the smart contract virtual machine runs the smart contract code to be debugged and pauses at the first line of executable code. This can effectively improve the running efficiency of subsequent smart contract codes.

[0082] In this embodiment, as an optional embodiment, the step further includes:

[0083] S206, the debugging front end sends a contract code acquisition request to obtain the smart contract code being debugged;

[0084] S207, the debugging backend receives the contract code acquisition request, calls the debugging agent to obtain the smart contract code running in the smart contract virtual machine, and carries the obtained smart contract code and the line number of the code breakpoint in the contract code acquisition request response, and returns it to the debugging frontend;

[0085] S208, the debugging front end displays the received contract code acquisition request response;

[0086] In this embodiment, the debugging front end receives the smart contract code and the line number of the code breakpoint, and displays the smart contract code and the line number of the code breakpoint to the user, so that the user can set the breakpoint information in the init function to be executed based on the displayed line number information of the code breakpoint.

[0087] In this embodiment, the smart contract code is displayed, and the breakpoint is set at the first line of the init function to be executed.

[0088] S209, the debugging front end receives the breakpoint information set by the user according to the displayed contract code to obtain the request response, and sends it to the debugging back end;

[0089] In this embodiment, the user can set breakpoint information through the debugging front end. After receiving the breakpoint information set by the user, the debugging front end encapsulates the breakpoint information in a code debugging command and sends it to the debugging back end.

[0090] In this embodiment, as an optional embodiment, the user can also set breakpoint information by initiating single-step debugging operations such as start over and step into, and implement code debugging of the smart contract code by setting a code debugging command containing breakpoint information.

[0091] In this embodiment, as an optional embodiment, websocket is used to send code debugging commands such as single-step debugging and breakpoints.

[0092] In this embodiment, by setting breakpoint information in the smart contract code, the execution can be paused when the breakpoint information in the smart contract code is reached, which is convenient for developers to check the value of variables and execute the code step by step. By using the single-step debugging single-step code execution method, by executing one line of smart contract code at a time, it is convenient to effectively debug the smart contract code.

[0093] S210, the debugging backend calls the debugging agent to drive the smart contract virtual machine to execute the code debugging command according to the code debugging command containing breakpoint information sent by the debugging frontend, and returns the execution result of the smart contract virtual machine to the debugging frontend.

[0094] S211, determining that all code debugging commands for the smart contract to be debugged have been executed.

[0095] In this embodiment, the debugging front end receives another code debugging command set by the user based on the displayed execution result, and sends it to the debugging back end until all code debugging commands are executed, thereby completing the deployment of the smart contract.

[0096] In this embodiment, as another optional embodiment, the step further includes:

[0097] S212, after completing the deployment of the smart contract, the debugging backend writes the smart contract code and debugging data into the blockchain ledger, and returns the transaction hash value and smart contract address that identify the debugging to the debugging frontend.

[0098] In this embodiment, after confirming that the operation of deploying the smart contract to be debugged is completed, the debugging backend writes the smart contract code and debugging data corresponding to the smart contract to be debugged into the blockchain account book for storage, and the debugging backend returns the transaction hash and smart contract address information to the debugging front end.

[0099] In this embodiment, during the debugging process, when sending data, the other party's blockchain public key is used to encrypt the data, and when receiving data, the data is decrypted using the blockchain private key of the user. If the user needs to start another debugging to deploy the smart contract, S201 can be re-executed.

[0100] S30, encapsulating a transaction request set for the smart contract to be debugged based on the web socket protocol, and driving the initialized smart contract virtual machine to run the smart contract to be debugged according to the transaction request, so as to perform functional debugging on the smart contract to be debugged;

[0101] In this embodiment, the user submits a transaction to the initialized blockchain where the smart contract to be debugged is deployed based on the transaction set for the smart contract to be debugged. The initialized blockchain runs the smart contract to be debugged to execute the transaction and obtain transaction information based on the received transaction.

[0102] In this embodiment, after the smart contract to be debugged is triggered to execute the transaction, the account data of the initialized blockchain can be changed. As an optional embodiment, the execution process of the transaction can be debugged step by step.

[0103] Figure 4 A flow chart of S30 in a smart contract debugging method provided in an embodiment of the present invention. In this embodiment, as an optional embodiment, the step includes:

[0104] S301, the debugging front end sends a debugging trigger contract request carrying transaction information to the debugging back end;

[0105] In this embodiment, as an optional embodiment, the start debugging trigger contract request (smart contract debuggable request) includes: transaction information, wherein the transaction information includes but is not limited to: the debugging type is a deployment contract transaction, the initiating account address of the transaction, the address of the smart contract to be debugged, the smart contract trigger parameters and signature information. As an optional embodiment, the start debugging trigger contract request example is as follows:

[0106] Tx=<<CALL_CONTRACT,SourceAddress,ContractAddress,input> , Signature>, where:

[0107] CREATE_CONTRACT: This transaction is a contract deployment transaction;

[0108] SourceAddress: the account address that initiated the transaction;

[0109] ContractAddress: smart contract address (the smart contract address to be debugged);

[0110] Input: Smart contract trigger parameters;

[0111] Signature:<CALL_CONTRACT,SourceAddress,ContractAddress,Input> The signature information of the smart contract trigger parameter, namely the signature information of the contract deployment transaction, the initiating account address, the smart contract address, and the smart contract trigger parameter.

[0112] S302, after the debugging backend receives the request to start debugging trigger contract, it starts the thread for verification;

[0113] In this embodiment, as an optional embodiment, the debugging backend first verifies the format of the transaction information carried in the debugging trigger contract request and the validity of the corresponding data; after the verification is passed, the JavaScript smart contract virtual machine is called to prepare to run the smart contract code to be debugged, and the smart contract trigger parameters are input to start the smart contract virtual machine.

[0114] S303, the debugging backend calls the debugging agent to start the smart contract virtual machine, and assigns values ​​to the initialized smart contract virtual machine according to the smart contract trigger parameters in the start debugging trigger contract request;

[0115] In this embodiment, after the initialized smart contract virtual machine in the deployment process is assigned a value according to the smart contract trigger parameter in the start debugging trigger contract request, the operation is suspended, and the information that the smart contract virtual machine debugging work is ready is returned, and the debugging command of the debugging front end is waited.

[0116] S304, the debugging front end sends a virtual machine parameter setting request set according to the transaction request to the debugging back end;

[0117] In this embodiment, after the debugging front end receives the smart contract virtual machine debugging work is ready, it sends a virtual machine parameter setting request to the debugging back end, so that the debugging back end sets the debugging parameters of the intelligent virtual machine according to the virtual machine parameter setting request, where the debugging parameters include but are not limited to: starting the debugger (intelligent virtual machine) parameters, pausing the program parameters when debugging exceptions occur, setting asynchronous call stack depth parameters, and starting running performance statistics parameters.

[0118] In this embodiment, as an optional embodiment, the virtual machine parameter setting request is sent via websocket.

[0119] S305, the debugging backend calls the debugging agent to set the debugging parameters based on the received virtual machine parameter setting request and triggers the smart contract virtual machine to run the smart contract to be debugged to process the submitted transaction, and returns a start debugging trigger contract request response carrying the debugging parameter setting result to the debugging front end.

[0120] In this embodiment, after the debugging backend receives the virtual machine parameter setting request sent by the debugging frontend, it calls the debugging agent to set the debugging parameters for the smart contract virtual machine, and returns the result after setting the debugging parameters to the debugging frontend. At the same time, the code is run to the first line of executable code and then the smart contract code to be debugged is run to process the transaction for debugging.

[0121] In this embodiment, as an optional embodiment, the step further includes:

[0122] S306, the debugging front end sends a request to obtain the debugging contract code to obtain the smart contract code being debugged;

[0123] In this embodiment, during the debugging process of the smart contract to be debugged, real-time query can be performed through the debugging front end.

[0124] S307: The debugging backend calls the debugging agent to obtain the smart contract code and the line number of the code breakpoint according to the received request to obtain the debugging contract code, and encapsulates it into a request response to obtain the debugging contract code, and returns it to the debugging frontend;

[0125] S308, the debugging front end displays the received request response for obtaining the debugging contract code;

[0126] In this embodiment, the debugging front end receives the smart contract code and the line number of the code breakpoint and displays them.

[0127] S309, receiving a debugging command including breakpoint information set by the user according to the information displayed by the debugging front end, and sending the breakpoint information to the debugging back end;

[0128] In this embodiment, the user can set breakpoint information according to the displayed information through the debugging front end. After receiving the breakpoint information set by the user, the debugging front end sends the debugging command containing the breakpoint information to the debugging back end.

[0129] In this embodiment, as an optional embodiment, the user can also initiate single-step debugging operations such as start over and step into.

[0130] S310, the debugging backend calls the smart contract virtual machine through the debugging agent to execute the received debugging command, and returns the execution result of the debugging command to the debugging front end;

[0131] S311, confirming that all debugging commands have been executed;

[0132] In this embodiment, as an optional embodiment, steps S309 to S310 are repeatedly executed until the operation of triggering the smart contract is completed.

[0133] S312, write the transaction data that triggers the smart contract into the blockchain ledger, and return the transaction hash information to the debugging front end.

[0134] In this embodiment, after the operation of triggering the smart contract is completed, the corresponding transaction data is written into the blockchain ledger. At the same time, the debugging backend returns the transaction hash information of the debugging to the debugging frontend so that the user can determine whether it is necessary to edit the smart contract code to be debugged.

[0135] S40, reading the debugging result of debugging the smart contract to be debugged, and adjusting the smart contract code corresponding to the smart contract to be debugged according to the debugging result and the preset scenario result corresponding to the smart contract to be debugged;

[0136] In this embodiment, the user can send a contract reading request, the blockchain executes the contract reading request, and returns the reading result information to the user.

[0137] In this embodiment, after reading the smart contract to be debugged, the ledger data of the blockchain changes accordingly. The execution process of the contract read request can be debugged step by step.

[0138] Figure 5 A flowchart of S40 in a smart contract debugging method provided in an embodiment of the present invention. In this embodiment, taking the input of a smart contract to be debugged as an example, as an optional embodiment, the step includes:

[0139] S401, the debugging front end initiates a request to read the debugging contract to the debugging back end;

[0140] In this embodiment, as an optional embodiment, the read debug contract request includes read parameter information. An example of the read debug contract request is as follows:

[0141] Tx=<QUERY_CONTRACT,SourceAddress,ContractAddress,input> in:

[0142] QUERY_CONTRACT: This transaction is a contract read transaction;

[0143] SourceAddress: the account address that initiated the transaction;

[0144] ContractAddress: smart contract address;

[0145] Input: Smart contract reading parameters;

[0146] S402, the debugging backend receives a request to read the debugging contract and starts a thread for verification processing;

[0147] In this embodiment, the format of the transaction and the validity of the data are first verified; finally, the JavaScript smart contract virtual machine is called to prepare to run the smart contract code and input the smart contract reading parameters.

[0148] S403, debugging the backend to start the smart contract virtual machine and initialize the smart contract virtual machine;

[0149] In this embodiment, after the smart contract virtual machine is initialized, the operation is suspended, and the smart contract virtual machine debugging work is ready information is returned to the debugging front end, and the debugging instructions of the debugging front end are waited.

[0150] S404, the debugging front end sends a contract debuggable setting request to the debugging back end to set the debugging parameters of the smart contract virtual machine;

[0151] In this embodiment, after the debugging front end receives the smart contract virtual machine debugging readiness information returned by the debugging back end, it sends a contract debuggable setting request to the debugging back end to set the relevant parameters for the smart contract virtual machine debugging, including but not limited to: starting debugger parameters, pausing program parameters when debugging exceptions, setting asynchronous call stack depth parameters, and starting running performance statistics parameters.

[0152] In this embodiment, as an optional embodiment, a contract debuggable setting request is sent via websocket.

[0153] S405, the debugging backend calls the debugging agent to set debugging parameters according to the received contract debuggable setting request;

[0154] In this embodiment, after the debugging backend receives the contract debuggable setting request sent by the debugging frontend, it calls the debugging agent, sets the relevant parameters in the smart contract virtual machine, and returns the result after setting the relevant parameters to the debugging frontend. At the same time, the code is run to the first line of executable code and paused.

[0155] S406, the debugging front end sends a request to obtain the debugging contract code to obtain the smart contract code being debugged;

[0156] S407: After receiving the request to obtain the debugging contract code, the debugging backend calls the debugging agent to obtain the line number of the smart contract code and the code breakpoint, and returns the obtained line number of the smart contract code and the code breakpoint to the debugging frontend;

[0157] S408, the debugging front end displays the number of lines of smart contract code and code breakpoints;

[0158] S409, receiving a debugging command set by the user according to the displayed information, and sending it to the debugging backend for debugging;

[0159] In this embodiment, the user can set breakpoint information through the debugging front end. After receiving the breakpoint information set by the user based on the displayed smart contract code and the line number of the code breakpoint, the debugging front end sends the breakpoint information to the debugging back end. In addition, the user can also initiate single-step debugging operations such as step over and step into.

[0160] S410, after receiving the debugging command from the debugging front end, the debugging back end executes the debugging command through the debugging agent and returns the execution result to the debugging front end;

[0161] S411, execute the new debugging command until the operation triggering the smart contract is completed;

[0162] In this embodiment, S409 to S410 are repeatedly executed until the operation of triggering the smart contract is completed.

[0163] S412, determine that the operation that triggers the smart contract is completed, and return the execution result after executing the smart contract to the debugging front end.

[0164] In this embodiment, if the user wants to start another debugging and reading contract, it can start from S401.

[0165] S50, re-debugging is performed according to the adjusted smart contract code, confirming that debugging of the smart contract to be debugged is completed, and releasing the initialized blockchain.

[0166] In this embodiment, after the debugging of the smart contract to be debugged is completed, the newly created initialization blockchain stops running. As an optional embodiment, the smart contract code to be debugged and the account book data of the initialization blockchain are cleared.

[0167] Figure 6 A flowchart of S50 in a smart contract debugging method provided in an embodiment of the present invention. In this embodiment, as an optional embodiment, the step includes:

[0168] S501, the debugging front end receives a request to close the debugging page input by the user, and sends a websocket connection disconnection request to the debugging back end;

[0169] In this embodiment, the user sends a request to close the debugging page through the debugging front end to close the websocket connection.

[0170] S502, the debugging backend starts a debugging shutdown thread according to the received websocket connection disconnection request;

[0171] S503, control the debugging shutdown thread to close the smart contract to be debugged in the debugging state, close the smart contract virtual machine, and delete the ledger data of the blockchain.

[0172] In this embodiment, smart contract debugging is performed based on the JavaScript virtual machine. By designing the entire debugging process from the debugging front-end to the debugging back-end, the debugging agent, and the smart contract virtual machine, a new dedicated blockchain instance is opened based on the smart contract debugging of each user, so that each opened blockchain instance is isolated from each other and does not affect each other, so that the debugging operations of each user can be executed concurrently, and newly created smart contracts can be debugged, and smart contracts that have been created on the blockchain can also be debugged, which effectively improves the debugging efficiency of smart contracts.

[0173] In this embodiment, for the debugging of smart contracts, by setting up three debugging methods, namely, deploying contracts, triggering contracts, and reading contracts, corresponding operation permissions are designed for each debugging method, thereby giving users richer debugging scenarios. Among them, the deployment contract can only debug the initialization function of the smart contract, the triggering contract can debug the read-write function of the contract, and the reading contract can debug the read-only function of the contract, thereby realizing all-round debugging of the smart contract. Furthermore, in this embodiment, the debugging front end and the debugging back end use two communication protocols for connection and communication. Among them, the HTTP protocol is used as the WEB page transmission protocol, and the WEBSOCKET protocol is used as the protocol for debugging instructions and result transmission. In this way, it can be compatible with different browsers, and the debugging results can be quickly responded to the debugging front end.

[0174] Based on the same inventive concept, Figure 7 As shown, an embodiment of the present invention further provides a debugging device for a smart contract, the device comprising:

[0175] The blockchain initialization module 701 is used to receive the smart contract to be debugged, initialize the blockchain network to obtain an initialized blockchain dedicated to debugging the smart contract to be debugged, and the initialized blockchain includes a smart contract virtual machine;

[0176] In this embodiment, as an optional embodiment, the blockchain initialization module 701 is specifically used for:

[0177] After the debugging front end establishes a connection with the debugging back end through the HTTP protocol, the debugging front end sends a web socket connection request to the debugging back end to obtain the web socket address and page service code of the debugging back end;

[0178] The debugging front end establishes a web socket connection with the debugging back end based on the acquired web socket address of the debugging back end;

[0179] The debugging front end sends a blockchain initialization request carrying request parameters to the debugging back end according to the received smart contract to be debugged, so that the debugging back end creates an initialized blockchain according to the received blockchain initialization request;

[0180] Obtain the blockchain information of the newly created initialized blockchain through the debugging front end;

[0181] Through the debugging front end, a new blockchain account for debugging the smart contract to be debugged is created in the initialized blockchain based on the blockchain information.

[0182] In this embodiment, as an optional embodiment, the debugging backend creates an initialization blockchain according to the received blockchain initialization request, including:

[0183] After the debugging backend establishes a websocket connection with the debugging frontend, a new blockchain including the intelligent virtual machine is created and the newly created blockchain is initialized according to the request parameters transmitted by the debugging frontend to form an initialized blockchain.

[0184] In this embodiment, as another optional embodiment, the debugging backend creates an initialization blockchain according to the received blockchain initialization request, including:

[0185] Based on the latest created blockchain, under the latest created blockchain, a forked chain including an intelligent virtual machine is newly created and the forked chain is initialized to form an initialized blockchain.

[0186] A smart contract deployment module 702 is used to deploy the smart contract to be debugged on the initialized blockchain based on the web socket protocol, and initialize the smart contract virtual machine on which the smart contract to be debugged is deployed to perform code debugging on the smart contract to be debugged;

[0187] In this embodiment, as an optional embodiment, the smart contract deployment module 702 is specifically used to:

[0188] Through the debugging front-end, send a request to start debugging and deploying the contract to the debugging back-end;

[0189] The debugging backend verifies the received request to start debugging and deploying the contract;

[0190] After the verification is passed, the debugging backend calls the debugging agent to initialize the smart contract virtual machine according to the smart contract initialization parameters carried in the start debugging and deploying contract request, and returns the start debugging and deploying contract request response to the debugging frontend;

[0191] The debugging front end responds to the received request to start debugging and deploying the contract, and after confirming that the debugging back end has been initialized, sends a parameter setting request for monitoring the operation of the smart contract to be debugged to the debugging back end;

[0192] The debugging backend calls the debugging agent to set the parameters carried in the parameter setting request in the smart contract virtual machine according to the received parameter setting request, and returns a parameter setting request response carrying the parameter setting result to the debugging front end.

[0193] In this embodiment, as another optional embodiment, the smart contract deployment module 702 is further used to:

[0194] The debugging agent returns the parameter setting request response to the smart contract virtual machine, so that the smart contract virtual machine runs the smart contract code to be debugged and pauses at the first line of executable code.

[0195] In this embodiment, as another optional embodiment, the smart contract deployment module 702 is further used to:

[0196] The debugging frontend sends a contract code acquisition request to obtain the smart contract code being debugged;

[0197] The debugging backend receives the contract code acquisition request, calls the debugging agent to obtain the smart contract code running in the smart contract virtual machine, and carries the obtained smart contract code and the line number of the code breakpoint in the contract code acquisition request response, and returns it to the debugging frontend;

[0198] The debugging front end displays the received contract code to obtain the request response;

[0199] The debugging frontend receives the breakpoint information set by the user based on the displayed contract code to obtain the request response, and sends it to the debugging backend;

[0200] The debugging backend calls the debugging agent to drive the smart contract virtual machine to execute the code debugging command based on the code debugging command containing breakpoint information sent by the debugging frontend, and returns the execution result of the smart contract virtual machine executing the code debugging command to the debugging frontend;

[0201] Make sure that all code debugging commands for the smart contract to be debugged have been executed.

[0202] The smart contract triggering module 703 is used to encapsulate the transaction request set for the smart contract to be debugged based on the web socket protocol, and drive the initialized smart contract virtual machine to run the smart contract to be debugged according to the transaction request, so as to perform functional debugging on the smart contract to be debugged;

[0203] In this embodiment, the user submits a transaction to the initialized blockchain where the smart contract to be debugged is deployed based on the transaction set for the smart contract to be debugged. The initialized blockchain runs the smart contract to be debugged to execute the transaction and obtain transaction information based on the received transaction.

[0204] The smart contract reading module 704 is used to read the debugging result of debugging the smart contract to be debugged, and adjust the smart contract code corresponding to the smart contract to be debugged according to the debugging result and the preset scenario result corresponding to the smart contract to be debugged;

[0205] In this embodiment, the user can send a contract reading request, the blockchain executes the contract reading request, and returns the reading result information to the user.

[0206] The blockchain release module 705 is used to re-debug according to the adjusted smart contract code, confirm that the debugging of the smart contract to be debugged is completed, and release the initialized blockchain.

[0207] In this embodiment, after the debugging of the smart contract to be debugged is completed, the newly created initialization blockchain stops running. As an optional embodiment, the smart contract code to be debugged and the account book data of the initialization blockchain are cleared.

[0208] Figure 8 A schematic diagram of a smart contract debugging system provided by an embodiment of the present invention. Figure 8 As shown, the smart contract debugging system includes: debugging front-end, debugging back-end, JavaScript smart contract virtual machine, debugging agent, blockchain ledger, among which,

[0209] The debugging frontend includes but is not limited to: browsers and clients, which are responsible for receiving the smart contract to be debugged input by the user, generating debugging instructions based on the smart contract to be debugged, and sending the smart contract to be debugged and debugging instructions to the debugging backend;

[0210] Receive the debugging result information returned by the debugging backend and display the debugging result information;

[0211] In this embodiment, by inputting the smart contract to be debugged into the debugging front end, corresponding debugging instructions are generated according to the function buttons displayed on the display interface of the debugging front end. As an optional embodiment, the debugging instructions include but are not limited to: deploying the smart contract code to be debugged, executing the smart contract to be debugged, starting debugging, resuming operation, stepping over, and stepping into. For example, the user can perform operations such as deploying the smart contract code to be debugged, executing the smart contract to be debugged, starting debugging, resuming operation, stepping over, and stepping into the smart contract to be debugged, obtain the debugging result information and use the debugging result information as the debugging output. As an optional embodiment, the debugging result information includes but is not limited to: contract address information, transaction address information, breakpoint information, and local variable information.

[0212] The debugging backend is used to call the page service according to the received debugging instructions and the smart contract to be debugged, send the debugging instructions and the smart contract to be debugged to the JavaScript smart contract virtual machine, receive the debugging result information obtained by the JavaScript smart contract virtual machine running the smart contract to be debugged according to the debugging instructions, call the page service, and send the debugging result information to the debugging frontend;

[0213] In this embodiment, as an optional embodiment, the page service includes but is not limited to: a debugging proxy server or a debugging proxy. Wherein, as an optional embodiment, the page service uses the HTTP protocol to provide services.

[0214] In this embodiment, as an optional embodiment, the debugging instructions and debugging result information are encapsulated and transmitted through the Websocket protocol. In this way, the debugging instructions, the smart contract to be debugged, and the debugging result information are forwarded through the Websocket protocol, which can respond to the request of the debugging front end in a timely manner, and transmit the debugging result information to the debugging front end for display in a timely manner, and can communicate in real time through a persistent connection; provide page services through the HTTP protocol, establish a connection when a request is received, and release the connection after the request is processed, which can effectively utilize the resources of the debugging back end.

[0215] The JavaScript smart contract virtual machine is used to process the smart contract to be debugged according to the received debugging instructions, obtain the debugging result information, write it to the blockchain ledger, and return the debugging result information to the debugging backend.

[0216] In this embodiment, the JavaScript smart contract virtual machine is responsible for executing the smart contract code and debugging the smart contract, and the blockchain ledger is responsible for the data access function of the smart contract.

[0217] Based on the same inventive concept, an embodiment of the present invention further provides a storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the smart contract debugging method in any possible implementation manner described above are implemented.

[0218] Alternatively, the storage medium may be a non-transitory computer-readable storage medium, for example, the non-transitory computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.

[0219] Based on the same inventive concept, see Fig. 9 The embodiment of the present invention further provides an electronic device, including a memory 101 (such as a non-volatile memory), a processor 102, and a computer program stored in the memory 101 and executable on the processor 102. When the processor 102 executes the program, the steps of the debugging method of the smart contract in any possible implementation method described above can be equivalent to the debugging device of the smart contract as described above. Of course, the processor can also be used to process other data or operations. The electronic device can be a PC, a server, a terminal, and other devices.

[0220] like Fig. 9 As shown, the electronic device may also generally include: a memory 103, a network interface 104, and an internal bus 105. In addition to these components, other hardware may also be included, which will not be described in detail.

[0221] It should be pointed out that the debugging device of the above-mentioned smart contract can be implemented by software. As a device in a logical sense, it is formed by the processor 102 of the electronic device in which it is located reading the computer program instructions stored in the non-volatile memory into the memory 103 for execution.

[0222] The embodiments of the subject matter and functional operations described in this specification may be implemented in the following: digital electronic circuits, tangibly embodied computer software or firmware, computer hardware including the structures disclosed in this specification and their structural equivalents, or a combination of one or more of them. The embodiments of the subject matter described in this specification may be implemented as one or more computer programs, i.e., one or more modules in computer program instructions encoded on a tangible non-temporary program carrier to be executed by a data processing device or to control the operation of the data processing device. Alternatively or additionally, the program instructions may be encoded on an artificially generated propagation signal, such as a machine-generated electrical, optical or electromagnetic signal, which is generated to encode information and transmit it to a suitable receiver device for execution by a data processing device. The computer storage medium may be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, or a combination of one or more of them.

[0223] The processes and logic flows described in this specification can be performed by one or more programmable computers executing one or more computer programs to perform the corresponding functions by operating on input data and generating output. The processes and logic flows can also be performed by special purpose logic circuits, such as FPGAs (field programmable gate arrays) or ASICs (application specific integrated circuits), and the apparatus can also be implemented as special purpose logic circuits.

[0224] Computers suitable for executing computer programs include, for example, general and / or special microprocessors, or any other type of central processing unit. Typically, the central processing unit will receive instructions and data from a read-only memory and / or a random access memory. The basic components of a computer include a central processing unit for implementing or executing instructions and one or more memory devices for storing instructions and data. Typically, the computer will also include one or more large-capacity storage devices for storing data, such as magnetic disks, magneto-optical disks, or optical disks, or the computer will be operably coupled to this large-capacity storage device to receive data from it or to transmit data to it, or both. However, the computer does not necessarily have such a device. In addition, the computer can be embedded in another device, such as a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a global positioning system (GPS) receiver, or a portable storage device such as a universal serial bus (USB) flash drive, to name a few.

[0225] Computer readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media and memory devices, including, for example, semiconductor memory devices (e.g., EPROM, EEPROM and flash memory devices), magnetic disks (e.g., internal hard disks or removable disks), magneto-optical disks, and CD-ROM and DVD-ROM disks. The processor and memory may be supplemented by, or incorporated in, special purpose logic circuitry.

[0226] Although this specification includes many specific implementation details, these should not be interpreted as limiting the scope of any invention or the scope of protection claimed, but are mainly used to describe the features of the specific embodiments of specific inventions. Certain features described in multiple embodiments in this specification may also be implemented in combination in a single embodiment. On the other hand, the various features described in a single embodiment may also be implemented separately in multiple embodiments or in any suitable sub-combination. In addition, although the features may work as above in certain combinations and even initially claim protection, one or more features from the claimed combination may be removed from the combination in some cases, and the claimed combination may point to a sub-combination or a variation of a sub-combination.

[0227] Similarly, although operations are depicted in a particular order in the accompanying drawings, this should not be understood as requiring that these operations be performed in the particular order shown or performed sequentially, or requiring that all illustrated operations be performed to achieve the desired results. In some cases, multitasking and parallel processing may be advantageous. In addition, the separation of various system modules and components in the above-described embodiments should not be understood as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product, or packaged into multiple software products.

[0228] Thus, specific embodiments of the subject matter have been described. Other embodiments are within the scope of the appended claims. In some cases, the actions recited in the claims can be performed in a different order and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the particular order or sequential order shown to achieve the desired results. In some implementations, multitasking and parallel processing may be advantageous.

[0229] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0230] The above is only a specific embodiment of the present invention, so that those skilled in the art can understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but should conform to the widest scope consistent with the principles and novel features applied herein.

Claims

1. A smart contract debugging method, It is characterized in that include: Receive a smart contract to be debugged, initialize a blockchain network to obtain an initialized blockchain dedicated to debugging the smart contract to be debugged, and the initialized blockchain includes a smart contract virtual machine; Based on the web socket protocol, deploy the smart contract to be debugged on the initialized blockchain, and initialize the smart contract virtual machine on which the smart contract to be debugged is deployed to perform code debugging on the smart contract to be debugged; Encapsulating a transaction request set for the smart contract to be debugged based on the web socket protocol, and driving the initialized smart contract virtual machine to run the smart contract to be debugged according to the transaction request, so as to perform functional debugging on the smart contract to be debugged; Reading a debugging result of debugging the smart contract to be debugged, and adjusting the smart contract code corresponding to the smart contract to be debugged according to the debugging result and a preset scenario result corresponding to the smart contract to be debugged; Re-debugging is performed according to the adjusted smart contract code, and debugging of the smart contract to be debugged is confirmed to be completed, and the initialized blockchain is released.

2. The smart contract debugging method according to claim 1, It is characterized in that The receiving of the smart contract to be debugged, initializing the blockchain network to obtain an initialized blockchain dedicated to debugging the smart contract to be debugged, wherein the initialized blockchain includes a smart contract virtual machine, including: After the debugging front end establishes a connection with the debugging back end through the HTTP protocol, the debugging front end sends a web socket connection request to the debugging back end to obtain the web socket address and page service code of the debugging back end; The debugging front end establishes a web socket connection with the debugging back end based on the acquired web socket address of the debugging back end; The debugging front end sends a blockchain initialization request carrying request parameters to the debugging back end according to the received smart contract to be debugged, so that the debugging back end creates an initialized blockchain according to the received blockchain initialization request; Obtain the blockchain information of the newly created initialized blockchain through the debugging front end; Through the debugging front end, a new blockchain account for debugging the smart contract to be debugged is created in the initialized blockchain based on the blockchain information.

3. The debugging method of the smart contract according to claim 2, It is characterized in that The debugging backend creates an initialization blockchain according to the received blockchain initialization request, including: After the debugging backend establishes a websocket connection with the debugging frontend, a new blockchain including the intelligent virtual machine is created and the newly created blockchain is initialized according to the request parameters transmitted by the debugging frontend to form an initialized blockchain.

4. The method for debugging a smart contract according to claim 2, It is characterized in that The debugging backend creates an initialization blockchain according to the received blockchain initialization request, including: Based on the latest created blockchain, under the latest created blockchain, a forked chain including an intelligent virtual machine is newly created and the forked chain is initialized to form an initialized blockchain.

5. The method for debugging a smart contract according to claim 1, It is characterized in that The method of deploying the smart contract to be debugged on the initialized blockchain based on the web socket protocol and initializing the smart contract virtual machine for deploying the smart contract to be debugged to perform code debugging on the smart contract to be debugged includes: Through the debugging front end, send a request to start debugging and deploying the contract to the debugging back end; The debugging backend verifies the received request to start debugging and deploying the contract; After the verification is passed, the debugging backend calls the debugging agent to initialize the smart contract virtual machine according to the smart contract initialization parameters carried in the start debugging and deploying contract request, and returns the start debugging and deploying contract request response to the debugging frontend; The debugging front end responds to the received request to start debugging and deploying the contract, and after confirming that the debugging back end has been initialized, sends a parameter setting request for monitoring the operation of the smart contract to be debugged to the debugging back end; The debugging backend calls the debugging agent to set the parameters carried in the parameter setting request in the smart contract virtual machine according to the received parameter setting request, and returns a parameter setting request response carrying the parameter setting result to the debugging front end.

6. The method for debugging a smart contract according to claim 5, It is characterized in that The method further comprises: The debugging agent returns the parameter setting request response to the smart contract virtual machine, so that the smart contract virtual machine runs the smart contract code to be debugged and pauses at the first line of executable code.

7. The method for debugging a smart contract according to claim 5, It is characterized in that The method further comprises: The debugging frontend sends a contract code acquisition request to obtain the smart contract code being debugged; The debugging backend receives the contract code acquisition request, calls the debugging agent to obtain the smart contract code running in the smart contract virtual machine, and carries the obtained smart contract code and the line number of the code breakpoint in the contract code acquisition request response, and returns it to the debugging frontend; The debugging front end displays the received contract code to obtain the request response; The debugging frontend receives the breakpoint information set by the user based on the displayed contract code to obtain the request response, and sends it to the debugging backend; The debugging backend calls the debugging agent to drive the smart contract virtual machine to execute the code debugging command based on the code debugging command containing breakpoint information sent by the debugging frontend, and returns the execution result of the smart contract virtual machine executing the code debugging command to the debugging frontend; Make sure that all code debugging commands for the smart contract to be debugged have been executed.

8. A debugging device for a smart contract, It is characterized in that The debugging device of the smart contract includes: A blockchain initialization module, used to receive a smart contract to be debugged, initialize a blockchain network to obtain an initialized blockchain dedicated to debugging the smart contract to be debugged, wherein the initialized blockchain includes a smart contract virtual machine; A smart contract deployment module, used to deploy the smart contract to be debugged on the initialized blockchain based on the web socket protocol, initialize the smart contract virtual machine for deploying the smart contract to be debugged, so as to perform code debugging on the smart contract to be debugged; A smart contract triggering module, used to encapsulate a transaction request set for the smart contract to be debugged based on the web socket protocol, and drive the initialized smart contract virtual machine to run the smart contract to be debugged according to the transaction request, so as to perform functional debugging on the smart contract to be debugged; A smart contract reading module, used to read the debugging result of the smart contract to be debugged, and adjust the smart contract code corresponding to the smart contract to be debugged according to the debugging result and the preset scenario result corresponding to the smart contract to be debugged; The blockchain release module is used to re-debug according to the adjusted smart contract code, confirm that the debugging of the smart contract to be debugged is completed, and release the initialized blockchain.

9. A storage medium, It is characterized in that The storage medium stores a program or instruction, and when the program or instruction is executed by the processor, the steps of the smart contract debugging method as described in any one of claims 1 to 7 are implemented.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the steps of the debugging method of the smart contract described in any one of claims 1 to 7 are implemented.