Protocol Environment Upgrade

Metastate
METASTATE
Published in
4 min readJul 28, 2020

Previously, we dove deep into BLS12–381, stateful baking accounts, delegation toggle, new Michelson opcodes, and PVSS, which were features under exploration and likely to be proposed to Tezos governance in the near future.

In this article, however, we are sharing the details of a new release of the Tezos shell, which includes a protocol environment upgrade. In spite of it not being a change in the Tezos protocol, we consider it indispensable for the community to know about, due to its close connection to some of the protocol features under exploration, such as the BLS12–381 elliptic curve integration or the Sapling integration.

Wild camel — from the Wild Camel Protection Foundation

Background and State of the Protocol Environment

The Tezos economic protocol is sandboxed, meaning that it only has access to its own functionalities, in addition to the ones provided by the environment. Examples of functionalities provided by the environment to the current protocol are cryptographic primitives, such as secp256k1, which is provided by a library written in C. Under the hood, the protocol is compiled with a specific version of the OCaml compiler that prevents the use of unsafe or non-wanted libraries. Additionally, the protocol environment* specifies a restricted set of modules that are available and required by the economic protocol. The environment does so by providing interfaces of the OCaml and Tezos standard libraries that are stripped of effects on toplevel references and channels, and of unsafe or deprecated functions.

The protocol environment also defines the interface that is offered to the economic protocol by the shell. Multiple environments can co-exist in the same shell, and each version is labelled with Vn where n is the version number, which starts at 0. Currently the economic protocol expects V0 of the environment.

Each economic protocol can only be compiled with the version of the environment specified in its TEZOS_PROTOCOL file, and its signature in main.mli has to match with that in updater.mli of the corresponding version of the environment. The file TEZOS_PROTOCOL includes a hash generated after the concatenation of the .ml files that implement the modules present in TEZOS_PROTOCOL. This hash, which is stored in the blockchain, enforces that the economic protocol implements the expected interface, and prevents changes to the interface of the economic protocol after its injection into the blockchain.

*For more in-depth background, see The Economic Protocol Environment and Compiler and Economic protocol sandboxing for a detailed account on protocol compilation and sandboxing.

Protocol Environment V1

An upgraded protocol environment V1 has been under development, in order to provide the dependencies that some of the features under exploration require. Among the improvements, the protocol environment V1 updates OCaml to version 4.09 and upgrades the Lwt library. Furthermore, it adds the Keccak and SHA3 hash functions from HACL*, adds support for the pairing-friendly BLS12–381 elliptic curve, and enables the inclusion of the new lib_sapling component to the Tezos architecture, which implements the required cryptographic components for the Sapling integration.

The GitLab issue Changes to the protocol environment describes these extensions in further detail.

Upgrading and Support for Multiple Environments

The protocol environment V1 is included in the regular release cycle of the Tezos shell. In addition to the development of V1, the necessary modifications in the shell have been made so that multiple environment versions can be supported simultaneously (V0 and V1).

If you are operating a Tezos node, we recommend following the regular shell release schedule and updating each node accordingly. In particular, the upcoming release, which contains both the current V0 and the new V1 environment versions. This way, should one of the possible protocol proposals be adopted by Tezos governance in the future, up-to-date nodes will already have the necessary environment dependencies required for the new protocol features.

Summary

In this article we aim to share the details of a new protocol environment (V1), which, although not being a protocol change, is closely related and required for some of the features that possible upcoming protocol proposals include, such as the BLS12–381 elliptic curve integration or the Sapling integration. The protocol environment V1 entails many improvements, including updates to OCaml, the Lwt library, and the Keccak and SHA3 additions from HACL*, as well as lib_sapling. Additionally, support for multiple environment versions (V0 and V1) in the Tezos shell has been enabled. Finally, in order to stay up-to-date with the aforementioned extensions, we recommend all Tezos node operators to continue following the regular shell release schedule.

More Tezos Protocol R&D Articles

More Resources

For feedback or questions, please do not hesitate to contact us: team@metastate.dev

Follow us on Twitter and Medium to stay tuned! 🐫

--

--