How RioChain follows the upgrade of Substrate FRAME

RioDeFi
3 min readMay 13, 2022

By Cloudgen Wong, Technology Director RioDeFi

The full name of “Substrate FRAME” is the Substrate’s framework of Runtime Aggregation of Modularized Entities (FRAME), which is one of the most essential components for providing module support in Substrate. For RioChain, one of the major upgrades of Substrate is to upgrade FRAME from version 1.0 to version 2.0.

Before explaining the technical aspects, let’s discuss the Substrate history.

Substrate is written in a programming language called Rust. Inside its programming language, there are different ways to reuse code including, traits and macros. Similar to C-programming language, the purpose of using macros is a metaprogramming technique that allows a piece of programming code to create other code during compilation. However, Rust language further improves macros by adding sub-categories of macros:

  • Declarative Macros (or derive macros): it is custom macros that specify code added with the derive attribute used on structs and enums.
  • Attribute-like Procedure Macros (or attribute macros): define custom attributes usable on any item.
  • Function-like Procedure Macros (or function macros): it looks like a function call but operates on the tokens specified as its argument.

Frame version 1.0 uses Declarative Macros. Shawn Tabrizi, Runtime Engineering Lead at Parity Technologies, explained in a post on stackoverflow.com

“It is not necessary to use the macros to develop on Substrate. As you may know, the macros ultimately expand to be real rust code, so if you understand the inner working of Substrate at that level, then of course you can write that code yourself, but this will certainly not be as easy as using the Macros.”

However, he has also admitted in the same post that those runtime macros can be hard to debug or work with.

On the other hand, one of the software engineers at Parity Technologies, Guillaume Thiolliere, being inspired by “Ink Macros”, proposed using “Attribute-like Procedure Macros” to replace the existing “Declarative Macros.” The proposal was adopted and a pull request was created, which became version 2.0 of the FRAME.

Shawn Tabrizi, described the change as “a solution to stay closer to traditional Rust syntax.”

The changes of FRAME not only involve macros but also components.

Moving from FRAME version 1.0 to version 2.0, more macros have been provided with detailed designs in FRAME components. RioChain has already upgraded the above features to keep up with FRAME’s development and is working with Certik to audit the new code. Once the audit and subsequent open testnet testing is complete, we will start implementing all the changes to upgrade RioChain’s mainnet.

However, the development of FRAME has not ended yet, the recent development of FRAME version 2.0 (in April 2022) includes the followings:

  • Supporting BEEFY (Bridge Efficiency Enabling Finality Yielder), BEEFY is a secondary protocol running along GRANDPA Finality to support efficient bridging with non-Substrate blockchains, currently mainly ETH Mainnet.
  • Add IPFS support as Remark storage

RioChain is currently reviewing these news features and planning for the next upgrade when these features become stable.

--

--