17 major breaking releases

new 20.0.0 Jan 14, 2025
19.0.0 Sep 26, 2024
18.0.0 Jul 18, 2024
17.0.0 Jul 12, 2024
0.0.0 Aug 31, 2023

#412 in Magic Beans

Download history 153/week @ 2024-09-28 122/week @ 2024-10-05 133/week @ 2024-10-12 192/week @ 2024-10-19 191/week @ 2024-10-26 269/week @ 2024-11-02 18455/week @ 2024-11-09 25055/week @ 2024-11-16 26812/week @ 2024-11-23 20210/week @ 2024-11-30 28870/week @ 2024-12-07 21568/week @ 2024-12-14 5976/week @ 2024-12-21 10874/week @ 2024-12-28 20144/week @ 2025-01-04 24896/week @ 2025-01-11

64,310 downloads per month
Used in 10 crates (via polkadot-sdk)

Apache-2.0

3MB
47K SLoC

Release

Polkadot SDK Stable 2412


lib.rs:

Safe Mode

Trigger for stopping all extrinsics outside of a specific whitelist.

Pallet API

See the pallet module for more information about the interfaces this pallet exposes, including its configuration trait, dispatchables, storage items, events, and errors.

Overview

Safe mode is entered via two paths (deposit or forced) until a set block number. The mode is exited when the block number is reached or a call to one of the exit extrinsics is made. A WhitelistedCalls configuration item contains all calls that can be executed while in safe mode.

Primary Features

  • Entering safe mode can be via privileged origin or anyone who places a deposit.
  • Origin configuration items are separated for privileged entering and exiting safe mode.
  • A configurable duration sets the number of blocks after which the system will exit safe mode.
  • Safe mode may be extended beyond the configured exit by additional calls.

Example

Configuration of call filters:

impl frame_system::Config for Runtime {
  // …
  type BaseCallFilter = InsideBoth<DefaultFilter, SafeMode>;
  // …
}

Entering safe mode with deposit:

Entering safe mode via privileged origin:

Exiting safe mode via privileged origin:

Low Level / Implementation Details

Use Cost

A storage value (EnteredUntil) is used to store the block safe mode will be exited on. Using the call filter will require a db read of that storage on the first extrinsic. The storage will be added to the overlay and incur low cost for all additional calls.

Dependencies

~18–34MB
~540K SLoC