Hangzhou: Which Novelties Can You Use Right Now?
In the early hours of December 4th, Tezos activated the Hangzhou protocol and Bitcoin price dropped by 20%. A coincidence? Not very likely. But seriously, Hangzhou is not a joke: it brings about features like a timelock-primitive, global constants, protocol-level cache, and reworked view functions. Let’s see, can we already use all those things.
We’ve read all we could find and tested everything we could reach.
Cache Is the Most Prominent Change
Tezos nodes now save the most recently called smart contracts in the RAM, in so-called hot storage. When the contract is re-executed, the node doesn’t have to load data from the hard drive and thus spends less gas. We checked the efficiency of caching on Quipuswap by comparing fees for tez/kUSD exchange and a much less popular tez/EASY. The difference turned out to be a staggering 37%, so the more popular contract definitely wins.
Timelock: For Devs Only (So Far)
Timelock is a transaction that remains hidden until a certain moment. They don’t allow flash-bots to outrun users and extract profits from decentralised exchanges.
The creators of Ligo and SmartPy have already included Timelock primitives and data types in the new versions of the languages and relevant documents. It is likely that Timelock applications for regular users will appear soon, but so far there are none.
New View: Faster and Safer
View is a function in Michelson which a contract can use to get data from the storage of a different contract. Before Hangzhou, the caller contract called the declarer contract to execute the view function and return the required data. It wasn’t very safe as the caller had no guarantee the declarer switched no data or the data remained the same after the event.
New view functions work differently: the caller executes the view function itself by actually reading data from the declarer contract’s storage. View, after all, is a synchronous function the contract executes before everything else. Now developers can boost the interaction between contracts.
Global Constants: Functionality Is There, Unlike the Constants
Devs have added global constants to the protocol, i.e. a table of hashes linked to Micheline values. A developer can import values of any constant into a smart contract from its hash. The most obvious use case of global constants is to import verified lambda functions and volume types to save space and avoid errors. We checked the table of current constants with API TzStats but it seems there’s nothing there yet.
Empty square brackets in the second line mean the server has returned an empty table.
Hangzhou in a Nutshell
Hangzhou gave developers new tools they have yet to use. But it’s alright since it’s only been a few days since the activation. The cache already works, though, and fees have gone down. But the next update called Idiazabal is going to be announced this month, so even more features seem to be in order.
Subscribe and never miss updates from the world of Tezos: