5

All the Substrate-based chains that I know of have no transactions in the genesis block. The genesis block is the same data structure as all other blocks and therefore does have a body and a Vec<Extrinsic> that could have some extrinsics in it.

I'm curious: was Substrate intentionally designed this way, or it just kind of turned out this way. And if it was not an intentional design decision, where might I look to make a genesis block that does have transactions in it?

Semantics of Genesis Transactions

I can think of two reasonable ways the semantics of such transactions might work.

  1. They are not executed and are basically just grafitti. They are a way to summarize the chain's pre-history at launch time.

  2. They are executed on top of some pre-state just like every other block. If this approach is taken, it would mean that any state set up in eg a chain spec file would be genesis pre-state.

Note that these two semantics are identical in the edge case where there are no transactions in the genesis block. So picking either one of them would be safe and not "break" old chains in any way.

Usecases for Genesis Transactions

I can think of a few usecases for having transactions in the genesis block.

  1. Setting a timestamp inherent in the genesis block.

  2. Remark: Chancellor on brink of Second bailout for Banks. (See also this question.)

  3. A more elegant way to express genesis state. This usecase relies on semantics #2. Many chains could start with a truly empty genesis pre-state, and then execute the genesis transactions to get the desired genesis state. As a classic example, consider a cryptocurrency that has no coins existing in the genesis pre-state and then has some mint extrinsics in the genesis block to create the initial distribution. This has the advantage that the genesis state can be constructed from the genesis block itself instead of distributed separately.

1

1 Answer 1

1

You can just add transaction to the genesis block. You are right that this isn't done by Polkadot or any of the Parachains. However, you can write your own BuildGenesisBlock implementation that can add whatever you want to the genesis block.

You have there control over what is added to the genesis state and control over the content of the genesis block aka the transactions.

2
  • Are you expecting genesis block building to still use the native runtime? I want to call a runtime api so that the runtime can generate the genesis extrinsics. But I don't yet have access to a client when building the genesis block. Or should I be using the CodeExecutor::call directly? Oct 16, 2023 at 18:07
  • Then you need to use the executor directly. The native runtime is not in any way related to this.
    – bkchr
    Oct 19, 2023 at 8:11

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.