Qtum Qtum released QIP-7: Qtum virtual machine upgrade, five major updates comprehensively improve development performance

QIP-7: Qtum virtual machine brand new upgrade

 

 

QIP-7 integrates the latest features of the Ethereum virtual machine, and at the same time has been comprehensively improved to make the Qtum virtual machine more powerful. The improvements in this update include: lower-cost cryptography built-in modules, new mathematical operators, storage gas cost optimization, and new methods for deploying smart contracts/interacting with smart contracts.

 

With these updates, it is believed that smart contract developers on the Qtum platform can build new types of applications to achieve better privacy, trust, security and availability in the Qtum decentralized ecosystem.

 

Virtual machine improvements

 

This update adds some new instructions to the virtual machine to improve the function of the virtual machine and reduce gas costs:

 

  1. Added the shift operators SHL and SHR as a supplement to other bit operators;

  2. Added extcodehash to reduce the cost of verifying whether the address has the expected smart contract code;

  3. Added the revert command to report error information to users and refund unused gas;

  4. Added staticcall instruction to call another contract in "read-only" mode;

  5. Provides an implementation that allows smart contract methods to return multiple values;

  6. The create2 instruction has been added, so the smart contract can be deployed to a predetermined address.

 

It is worth mentioning that the addition of the create2 command makes it possible to create a "counterfactual contract". Before that, the address part of the smart contract was determined by the nonce of its creator, so it was unpredictable. With Create2, developers can predetermine the address of the smart contract without actually deploying the code. This is very useful because some of the details of the smart contract logic may not be available to the public now unless the relevant parties need these details. This is like an impartial arbitrator who will follow the instructions in the sealed envelope when a dispute arises.

 

Counterfactual smart contracts enable a generalized state channel (generalized state channel) [1] to be implemented on Qtum, thereby enabling off-chain privacy solutions.

 

Cryptography improvements

 

The Qtum smart contract virtual machine is a general computing platform. Although developers can directly implement any encryption algorithm in a smart contract, doing so is often too expensive for actual use. Encryption algorithms usually require special optimization to run effectively.

 

This update introduces highly optimized mathematical function implementations, which greatly reduces the gas cost of some interesting algorithms and makes them suitable for actual use scenarios.

 

Large integer arithmetic

 

The virtual machine is optimized for 256-bit integers and can be used to implement modern Elliptical Curve Cryptography (ECC) algorithms. However, older encryption algorithms like RSA rely on different mathematical entities, and these entities require more bits to achieve the same security. The current guidelines for the use of RSA suggest using a 4028-bit long public key to achieve the same security as a 256-bit long ECC public key.

 

In order to support these algorithms, this update introduces some efficient and lower-cost methods to implement mathematical operations on numbers greater than 256 bits. This is achieved by adding a pre-compiled contract that supports the following operations (and related gas costs):

  1. GADDSUBBASE: 15

  2. GMULDIVBASE: 30

  3. GMODEXPBASE: 45

  4. GARITHWORD: 6

  5. GQUADDIVISOR: 32

 

ZK-SNARKs support

 

What is exciting is that the zero-knowledge proof system makes it possible to build privacy-related applications on the Qtum blockchain. However, the type of elliptic curve that these systems rely on is different from the native elliptic curve used by Qtum.

 

This update adds support for the alt_bn128 curve, which is the curve used by many zk-snarks systems. In particular, this is the curve chosen by the cryptocurrency ZCash.

 

Optimization of stored gas cost

 

The cost of storing data on the blockchain is high, because each storage item will be stored in each node of the network, and it will be stored forever! However, the implementation of the storage instruction sstore is actually optimized to reduce storage costs in some cases, but the system will still charge the same amount of gas. This update reduces the gas cost in some special cases. In these cases, the sstore instruction can be optimized.

 

Consider using the following commands in smart contract calls to set position 0x0 to different numbers:

sstore 0x00 0x1

sstore 0x00 0x2

sstore 0x00 0x3

 

In this sequence, actually only the last sstore instruction will have an impact on the cost, because the last set number is the final number on the chain. All these instructions previously required high gas costs. With this update, only the cost of the last instruction is high, while the cost of executing the previous instructions is very low.

references

 

1.https://www.counterfactual.com/statechannels/

 

Guess you like

Origin blog.csdn.net/weixin_42667079/article/details/101348197