2

Like if I were to add some custom logic and checks to ensure only certain kind of blocks are produced by the validators or only those blocks that contain a certain size of data are produced then where in code should I look for or what files should I change?

I tried looking up at the BABE-pallet but it only contained logic regarding validator selection and stuff.

I want to know where this block production/building takes place in code and how I can modify that logic to allow only certain blocks to be added by validators.

1 Answer 1

3

Simply put, BABE(-pallet) provides logic which decides who, for a certain amount of blocks, is allowed to author a new block.

Authoring a block is filling the block with valid transactions from the transaction pool and sending it to other peers. But blocks are blocks, and the only way to specify what kind of blocks are allowed is specifying what kind of transactions are allowed in the blocks. This is your runtime, more specifically, the pallets you include in your runtime that provide the functionality for certain transactions on your chain. For example, again simply put, without the nft-pallet configured in your runtime you can't send nft related transactions on that particular chain. In addition, there are some constants that you could modify (e.g. block size, block length, etc) in order to specify the "size" of the blocks.

4
  • I tried to look for the code where a polkadot validator "makes" a block but I couldn't find it. Can someone help us by sharing a link to the relevant code? Commented Feb 6, 2023 at 15:31
  • 2
    you might be interested in looking at the BlockBuilder runtime Api and paritytech.github.io/substrate/master/sc_block_builder/… Commented Feb 6, 2023 at 17:15
  • 1
    @DaanvanderPlas I wanted to know about the particular part of code where a validator forms a blocks and adds to their local version of the chain and then broadcasts it. Basically I want to modify the empty-block production logic and kinda a build a mixture of instant-seal + BABE. Commented Feb 10, 2023 at 8:12
  • @Purple_Turtle's suggestion is more on point. Look into. github.com/paritytech/substrate/blob/…
    – kianenigma
    Commented Mar 8, 2023 at 16:58

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.