4

During the sudo phase of a parachain integration, when uploading balances and vested balances for crowdloan participants, we need to make sure that those balances cannot be transferred until the next phase. We need a runtime filter so that account holders cannot transfer balances.

What extrinsics can we use to enable this functionality?

2 Answers 2

4

As @bkchr pointed out, you want to use a BaseCallFilter which is configured inside of your runtime for the frame_system Pallet.

/// Use this filter to block users from calling any functions in the Balances pallet.
pub struct DontAllowBalances;
impl Contains<Call> for DontAllowBalances {
    fn contains(c: &Call) -> bool {
        // This will match against any call from the Balances pallet.
        !matches!(c, Call::Balances(..))
    }
}

Then you configure your System pallet to use this filter:

impl frame_system::Config for Runtime {
    type BaseCallFilter = DontAllowBalances;
    // -- snip --
}

This works for any pallet or call, and is how Polkadot and other chains disabled transfers or other kinds of calls in the bootstrapping stages of the network.

See this PR which is the one which enabled balance transfers on Polkadot and uses this same feature: https://github.com/paritytech/polkadot/pull/1443

1
  • btw, sudo ignores BaseCallFilter Commented Feb 23, 2022 at 12:35
2

A runtime BaseCallFilter can not be set with an extrinsic. You need to set the filter in your runtime "statically". It is also best advised to write the filter in such a way that you allow calls explicitly instead of having wildcards. Be aware that Sudo ignores BaseCallFilter.

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.