2

I will like to play with limiting the max size of transactions? I cannot find in substrate where those configurations go.

1 Answer 1

1

FRAME does not have a limit on a single transaction, but does have a limit for a single block. Then any transaction would be limited to the size limit of that block.

You can find those settings in the frame_system::Config configuration, specifically the BlockLength configuration:

/// System configuration trait. Implemented by runtime.
#[pallet::config]
#[pallet::disable_frame_system_supertrait_check]
pub trait Config: 'static + Eq + Clone {
    /// The basic call filter to use in Origin. All origins are built with this filter as base,
    /// except Root.
    type BaseCallFilter: Contains<Self::Call>;

    /// Block & extrinsics weights: base values and limits.
    #[pallet::constant]
    type BlockWeights: Get<limits::BlockWeights>;

    /// The maximum length of a block (in bytes).
    #[pallet::constant]
    type BlockLength: Get<limits::BlockLength>;

    /// -- snip --
}

The structure here: https://github.com/paritytech/substrate/blob/master/frame/system/src/limits.rs

If you wanted to create some logic which rejects transactions based on their individual length, you could create a SignedExtension.

An example of that can be found in the example pallet: https://github.com/paritytech/substrate/blob/master/frame/examples/basic/src/lib.rs#L674

3
  • Thanks, for clarity, there is currently no validation on the size of the extrinsic? So if my transaction takes a vector as param Vec<u8> there is nothing limiting the size? In short, a single transaction can take the whole block size?
    – Yatusabes
    Commented May 12, 2022 at 22:16
  • 1
    I think so, but users are also paying a "per byte fee". So it is not cheap at all to submit large transactions like this. Would be basically the same cost as submitting 100 transactions which fill up the block...
    – Shawn Tabrizi
    Commented May 12, 2022 at 23:06
  • i have increased my BlockLength and i still cannot send a single extrinsic with over 4MB of data. is there anything else limiting the size? Commented Jan 5 at 17:24

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.