With Developers in Mind: Hangzhou Update Review
Just two months ago, Tezos welcomed the new update titled Granada. But things never stay still, so in late September the devs rolled out a new proposal, Hangzhou, named after the heartland of China’s IT industry.
The Hangzhou update seeks to enhance the safety of user funds, accelerate smart contract execution, and make development more comfortable. It will also extend the liquidity baking until at least the ninth update. At the press time, Hangzhou has entered the second voting phase. You can check the acceptance progress at Tezos Agora.
In this post, we talk about the novelties of Hangzhou: timelock, on-chain views, global constants, and cache.
Timelock is a type of smart contract basics that forbids the contents of a transaction to be seen until a specified time. It is required to protect Tezos users from so-called “forward trading.” In an example, Alice calls a Quipuswap contract to exchange tokens. The baker creating the current block sees the transaction, and theoretically can create a similar request for Quipuswap, but put it earlier in the block than Alice’s request. Blockchain, therefore, will execute the baker’s transaction faster, and the baker will profit from trading against Alice.
Timelock will enable users to encrypt important transactions. A timelock contract will transfer decryption keys to the baker moments before the inclusion of the transaction into the block. Thus, the baker won’t be able to create a competing transaction and profit from de-facto seeing the future.
Michelson On-Chain Views
View functions of contracts are there to see the storage state of other smart contracts. Currently, the first contract’s View requests data, and the second contract returns it, which has a vulnerability: the first contract has no guarantee whatsoever that the second contract hasn’t switched data in some way. Marigold devs, therefore, have offered a new primitive View that grants smart contracts reading rights for other contracts’ storages. Thus, the requested contract finds itself incapable of changing the data.
The size of smart contracts is heavily limited, so developers have to go lots of extra miles to write complex logic, which may result in limited functionality for the sake of saving precious bytes. Hangzhou can solve this problem thanks to the global table of constants. Devs will register the most frequently used functions and bulky data types there, and then just call their hash in the contract. Pretty convenient, huh?
The global table of constants can become something like a decentralised library for re-using code and saving space in the contract. The table will also make future contracts safer as devs will be using reliable code that had been used and proven before.
Blockchain stores all the data on bakers’ hard drives. Even though today’s SSD can read and write pretty fast, blockchain spends too much time to search and read contract codes, as well as to rewrite storage states, stake distribution, and other operations with smart contracts.
The Nomadic Labs team developed the concept of cache that stores frequently used data in bakers’ RAM. the network will get contract codes and storage states faster, and therefore executes popular operations like DEX exchange or popular token transfer faster, too.
Subscribe and never miss a thing: