4

I am a curious learner and on my way of understanding the core principles of the Substrate universe + going through the tutorials on substrate.io.

As far as I understood is: there exists a Core Runtime (chain runtime) and this runtime can be extended with default pallets (aka runtime modules) from FRAME or own developed runtime modules.

2 questions arose when I had a look at this diagram that shows the architectural overview of FRAME:

  1. Are system modules a kind of add ons to Runtime modules (aka Pallets) and CAN be used but it is NOT a must?

  2. If system modules are a kind of 'nice to have', do they change the structure of the Runtime / Runtime modules in any way?

Thank you in advance and let me know, if more information is required or my request doesn't meet the StackExchange principles.

I appreciate your time and work on that!

BR Cindy

3 Answers 3

2

Here's my 2 cents.

Let's step back a little and start from the basics. As you may know, a node is a computer participating in the blockchain network, and there is an application, known as a client, running in it.

This is a conceptual diagram of a Substrate client.

The runtime, labeled as Wasm Runtime, is a piece of the Substrate client. There are other components besides the runtime that comprise the Substrate client.
From the docs:

The runtime of a blockchain is the business logic that defines its behaviour.

This business logic is organized in domain-specific modules. Broadly speaking, we refer to these modules as FRAME modules (pallets). So, we could say that a set of pallets constitute a runtime.

In the Substrate Node Template repository, you could check how the runtime is constructed based on a set of pallets. You could navigate to runtime/src/lib.rs and find the construct_runtime! macro.

You will see the following:

// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
    pub enum Runtime where
        Block = Block,
        NodeBlock = opaque::Block,
        UncheckedExtrinsic = UncheckedExtrinsic
    {
        System: frame_system,
        RandomnessCollectiveFlip: pallet_randomness_collective_flip,
        Timestamp: pallet_timestamp,
        Aura: pallet_aura,
        Grandpa: pallet_grandpa,
        Balances: pallet_balances,
        TransactionPayment: pallet_transaction_payment,
        Sudo: pallet_sudo,
        // Include the custom logic from the pallet-template in the runtime.
        TemplateModule: pallet_template,
    }
);

All the pallets except TemplateModule are FRAME modules provided by Substrate.
TemplateModule is a custom pallet written by a developer.

Back to your questions, in the link you shared at the System crate section says:

All other pallets depend on the System crate (pallet_system) as the basis of your Substrate runtime. The System crate defines all the core types for the Substrate runtime.

Based on that, the System pallet, which is part of the "SYSTEM MODULE" block in the diagram, is a must.

1
  • That' great! Thank you so much. BR, Cindy
    – Cindita
    Mar 14, 2022 at 18:41
1

Okey because you are using FRAME framework. frame_system and frame_support pallets are a must because they give you low level types to work on into your custom pallets and also low level functions.

For example (I hope you know Rust) the return type of a function that is callable to outside world is found in frame_support. Lets go to the low level functions. For example if you want to get a blocknumber currently. That function is inside frame_system. And among other functions and return types. So these low level pallets are very essential. Hope I answered your questions

1

The system module is essential for your pallet, which is why it's usually bound to the Config trait of pallets (unless you want to re-write all the needed types like BlockNumber, AccountId etc, which is counter-productive). It contains all the core types that most runtimes will be using.

1
  • Thank you very much!
    – Cindita
    Mar 14, 2022 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.