https://blog.broxus.com/
BlogLocklift upgrade: Improved smart contrac...

Locklift upgrade: Improved smart contract testing and performance

Sep 14 • 3 min read

We have just introduced a new version of the Locklift framework for writing, deploying and testing smart contracts on Threaded Solidity. This new version supports a new transport that outperforms the previously utilized local GQL node transport used to connect to Locklift. Moreover, it opens new and much more convenient ways to debug smart contracts. Today, we are going to breakdown the new functionality and share some thoughts on further Locklift development.

Setting up Locklift

By default, new projects will use the new Locklift transport. If you want to use the new transport on projects that have already been launched, you will have to add a new network with a proxy connection type in your Locklift configuration file:

networks: {
   locklift: {
       connection: {
           id: 1001,
           // @ts-ignore
           type: "proxy",
           // @ts-ignore
           data: {},
       },
       keys: {
           amount: 20,
       },
   },
   // other networks
}

Lightweight proxy transport for improved performance

The new version of Locklift allows you to use a new lightweight proxy transport, which delivers enhanced performance and better resource efficiency. By design, the new transport does not require making API calls to the local node for smart contract execution. Instead, the proxy works inside the preconfigured Locklift network, which uses a local iteration of the Threaded Virtual Machine (TVM) and can imitate any blockchain scenario. In other words, smart contract execution is conducted right in Locklift.

Since smart contracts are no longer executed in a discrete local node process that also involves processing the full logic of the Everscale blockchain, the speed of executing smart contracts is at least two times higher with new proxy transport. Moreover, it is capable of processing much larger batches of transactions.

The animations below demonstrate the differences between testing smart contract executions with a local node and right from the Locklift network.

This is how smart contracts were deployed to the network state, downloaded to the local node and invoked via local node API calls:

And this is how smart contracts are tested within the Locklift network:

We mentioned that the Locklift network is preconfigured to have all the necessary features for smart contract development and testing. If you need a specific environment for your smart contract execution, you can reconfigure the Locklift network to adjust the environment in accordance with your requirements. Its flexibility and independence from the local node creates new opportunities to implement various features into the process of smart contract development. With Locklift, writing smart contracts on Threaded Solidity for blockchains compatible with Threaded Virtual Machine (TVM) compatible is more comfortable and less rigid.

Transparent and easy smart contract testing

While working on the current version of Locklift, we were very conscious of the need to upgrade the current way smart contracts are tested.

Tracing now works with any transport as it does not require GraphQL URLs. And, if you use the JRPC connection type, tracing will also be available for your project.

If you use the new proxy transport, a traceback will highlight the line of solidity code where an exception occurred.

An example of a traceback that highlights the code line in the new version of Locklift.

Future of Locklift

The new proxy transport creates many opportunities for the further development of the Locklift framework. This has allowed us to create a new, ambitious roadmap that includes the development of instruments that will enable the following:

  • Conducting tests on a forked network. It will greatly reduce the complexity of writing smart contracts, relying on the infrastructure already deployed in the network. Smart contract developers will not be required to write mocks for tests and smart contract testing will be conducted as if the contracts were deployed right to the mainnet.
  • Taking snapshots of the virtual machine state and reverting to it after conducting a test. This comes in handy when you have to conduct smart contract testing with a complex parallel logic. A snapshot of the virtual machine (VM) state allows using a fixture only once and recovering the VM state after each test. 
  • Analysing code. The framework will highlight the gas expenses of the different code blocks.
  • Setting breakpoints to stop and resume the code execution at the select lines to check the integrity of the data used.

There is much work done to make the development process for TVM-compatible blockchains pleasant and convenient for developers. And there is much work to be done to devise more new features. 

To discover the full power of Locklift, visit the corresponding page: locklift.io. Stay tuned!

Related

Threaded Solidity: How to write smart contracts for TVM-compatible blockchains
A definitive guide from Broxus, which will help you start creating smart contracts on Threaded Solidity like a pro.
Sep 18
August 2023 Crypto Revue: The impact of the digital ruble and a special report on PayPal
PayPal unveils its stablecoin, EU studied the impact of CBDC on monetary policy, new US banking regulations will affect crypto, and other news.
Aug 29