Module tuxedo_core::inherents

source ·
Expand description

APIs and utilities for working with Substrate’s Inherents in Tuxedo based chains.

§Substrate inherents

Inherents are a Substrate feature that allows block authors to insert some transactions directly into the body of the block. Inherents are similar to pre-runtime digests which allow authors to insert info into the block header. However inherents go in the block body and therefore must be transactions.

Classic usecases for inherents are injecting and updating environmental information such as a block timestamp, information about the relay chain (if the current chain is a parachain), or information about who should receive the block reward.

In order to allow the runtime to construct such transactions while keeping the cleint opaque, there are special APIs for creating inherents and performing off-chain validation of inherents. That’s right, inherents also offer a special API to have their environmental data checked off-chain before the block is executed.

§Complexities in UTXO chains

In account based systems, the classic way to use an inherent is that the block inserts a transaction providing some data like a timestamp. When the extrinsic executed it, overwrites the previously stored timestamp in a dedicated storage item.

In UTXO chains, there are no storage items, and all state is local to a UTXO. This is the case with, for example, the timestamp as well. This means that when the author calls into the runtime with a timestamp, the transaction that is returned must include the correct reference to the UTXO that contained the previous best timestamp. This is the crux of the problem: there is no easy way to know the location of the previous timestamp in the utxo-space from inside the runtime.

§Scraping the Parent Block

The solution is to provide the entirety of the previous block to the runtime when asking it to construct inherents. This module provides an inherent data provider that does just this. Any Tuxedo runtime that uses inherents (At least ones that update environmental data), needs to include this foundational previous block inherent data provider so that the Tuxedo executive can scrape it to find the output references of the previous inherent transactions.

Structs§

  • An adapter type to declare, at the runtime level, that Tuxedo pieces provide custom inherent hooks.
  • An inherent data provider that inserts the previous block into the inherent data. This data does NOT go into an extrinsic.

Constants§

Traits§

  • Tuxedo’s controlled interface around Substrate’s concept of inherents.