Protocol Hangzhou

This page contains all the relevant information for protocol Hangzhou (see Protocol naming).

The code can be found in the src/proto_011_PtHangzH directory of the master branch of Tezos.

This page documents the changes brought by protocol Hangzhou with respect to Granada.

New Environment Version (V3)

This protocol requires a different protocol environment than Granada. It requires protocol environment V3, compared to V2 for Granada. (MR !3040)

Receipts, Balance Updates

  • Breaking change: Rewards balance updates for nonce revelations or endorsements now mention the cycle at which the rewards were granted instead of the cycle of the level carried by the operation. Likewise for deposits balance updates related to endorsement operations, they now mention the cycle at which the funds have been deposited. (MR !3270)

RPC Changes

  • Deprecated RPC POST ../endorsing_power has been removed. Clients already used GET ../helpers/endorsing_rights which is clearer, as powerful and equally costly in terms of computation for the node. (MR !3395)

  • The RPCs GET ../context/delegates/[PUBLIC_KEY_HASH]/.. now fail gracefully with a specific error delegate.not_registered when PUBLIC_KEY_HASH is not a delegate instead of the generic context.storage_error. (MR !3258, issues #450, #451, and #1276)

Timelock

  • Added timelock-related types and opcodes to Michelson. They allow a smart contract to include a countermeasure against Block Producer Extractable Value. More info in Timelock. (MRs !3160 !2940 !2950 !3304 !3384)

Michelson On-Chain Views

Views are a new mechanism for contract calls that:

  • are read-only: they may depend on the contract storage but cannot modify it nor emit operations (but they can call other views);

  • take arguments as input in addition to the contract storage;

  • return results as output;

  • are synchronous: the result is immediately available on the stack of the caller contract.

There are two added Michelson primitives: VIEW (instruction) and view (top-level keyword).

Global Constants

  • A new manager operation and corresponding CLI command have been added allowing users to register Micheline expressions in a global table of constants, returning an index to the expression. A new primitive constant <string> has been added that allows contracts to reference these constants by their index. When a contract is called, any constants are expanded into their registered values. The result is that users can use constants to originate larger contracts, as well as share code between contracts.

  • TZIP

  • MRs: !2962, !3467, !3473, !3492

Cache

  • A chain-sensitive cache is now available to the protocol developers. This cache can be seen as an in-memory context providing fast access to the most recently used values.

  • The protocol now keeps contracts’ source code and storage in the cache. This reduces the gas consumption for the most recently used contracts.

  • The new RPC context/cache/contracts/all returns the list of contracts in the cache.

  • The new RPC context/cache/contracts/size returns an overapproximation of the cache size (in bytes).

  • The new RPC context/cache/contracts/size_limit returns the maximal cache size (in bytes). When this size is reached, the cache removes the least recently used entries.

  • The new RPC context/cache/contract_rank gives the number of contracts that are less recently used than the one provided as argument.

  • The new RPC scripts/script_size gives the size of the script and its storage when stored in the cache.

  • MRs: !3234 !3419

  • Gas instrumentation implemented in MR !3430

Context Storage Flattening

Hex-nested directories like /12/af/83/3d/ are removed from the context. This results in better context access performance. (MR !2771)

Gas computation has been adapted to this new flattened context layout. (MR !2771)

Bug Fixes

  • A bug in Michelson comparison function has been fixed (MR !3237)

  • Fix balance updates that indicate inaccurate burned amounts in some scenarios (MR !3407)

Minor Changes

  • Gas improvements for typechecking instruction CONTRACT (MR !3241)

  • Other internal refactorings or documentation. (MRs !2021 !2984 !3042 !3049 !3088 !3075 !3266 !3270 !3285 !3375 !3247)

  • Set the predecessor version of the protocol to Granada (MR !3347)

  • Check order in the validation of endorsements has changed to not compute all endorsement slots of a level if the endorsement is invalid. (MR !3395)

  • Fix handling of potential negative integer in Raw_level_repr encoding. (MR !3273)

  • RPCs GET ../helpers/endorsing_rights and GET ../helpers/baking_rewards have been moved into the RPC plugin. Nothing has changed from the end-user perspective for now but further improvements to their performance will become easier now that they are decoupled from the protocol development cycle. (MR !3368)

  • Gives an increase to the liquidity baking sunset level of 211,681 blocks, or five voting periods plus 6,881 blocks to sync with the following voting period, roughly an additional two months and a half. Without this, the subsidy would halt during the lifespan of this protocol. With this change the subsidy can continue until the protocol after this one is activated, even accounting for some delays in proposal injection and/or a restarted voting process, while still making sure it won’t extend to two protocols after this one without a more significant increase. This follows the spirit of the liquidity baking TZIP in that it is still roughly six months from Granada activation and requires a referendum on the subsidy in the protocol after this one. (MR !3425 !3464)

  • Reimplemented Logging. It now has Lwt-less APIs and the messages are handled by the shell. (MR !3225)

  • The size limit on Michelson types has been roughly doubled (from 1000 to 2001). (MR !3434)