Skip to content

SafeMode


Calls


enter

Enter safe-mode permissionlessly for [Config::EnterDuration] blocks.

Reserves [Config::EnterDepositAmount] from the caller's account. Emits an [Event::Entered] event on success. Errors with [Error::Entered] if the safe-mode is already entered. Errors with [Error::NotConfigured] if the deposit amount is None.

Attributes

No attributes

Python

call = substrate.compose_call(
    'SafeMode', 'enter', {}
)

extend

Extend the safe-mode permissionlessly for [Config::ExtendDuration] blocks.

This accumulates on top of the current remaining duration. Reserves [Config::ExtendDepositAmount] from the caller's account. Emits an [Event::Extended] event on success. Errors with [Error::Exited] if the safe-mode is entered. Errors with [Error::NotConfigured] if the deposit amount is None.

This may be called by any signed origin with [Config::ExtendDepositAmount] free currency to reserve. This call can be disabled for all origins by configuring [Config::ExtendDepositAmount] to None.

Attributes

No attributes

Python

call = substrate.compose_call(
    'SafeMode', 'extend', {}
)

force_enter

Enter safe-mode by force for a per-origin configured number of blocks.

Emits an [Event::Entered] event on success. Errors with [Error::Entered] if the safe-mode is already entered.

Can only be called by the [Config::ForceEnterOrigin] origin.

Attributes

No attributes

Python

call = substrate.compose_call(
    'SafeMode', 'force_enter', {}
)

force_exit

Exit safe-mode by force.

Emits an [Event::Exited] with [ExitReason::Force] event on success. Errors with [Error::Exited] if the safe-mode is inactive.

Note: safe-mode will be automatically deactivated by [Pallet::on_initialize] hook after the block height is greater than the [EnteredUntil] storage item. Emits an [Event::Exited] with [ExitReason::Timeout] event when deactivated in the hook.

Attributes

No attributes

Python

call = substrate.compose_call(
    'SafeMode', 'force_exit', {}
)

force_extend

Extend the safe-mode by force for a per-origin configured number of blocks.

Emits an [Event::Extended] event on success. Errors with [Error::Exited] if the safe-mode is inactive.

Can only be called by the [Config::ForceExtendOrigin] origin.

Attributes

No attributes

Python

call = substrate.compose_call(
    'SafeMode', 'force_extend', {}
)

force_release_deposit

Force to release a deposit for an account that entered safe-mode at a given historical block.

This can be called while safe-mode is still entered.

Emits a [Event::DepositReleased] event on success. Errors with [Error::Entered] if safe-mode is entered. Errors with [Error::NoDeposit] if the payee has no reserved currency at the specified block.

Can only be called by the [Config::ForceDepositOrigin] origin.

Attributes

Name Type
account T::AccountId
block BlockNumberFor<T>

Python

call = substrate.compose_call(
    'SafeMode', 'force_release_deposit', {
    'account': 'AccountId',
    'block': 'u32',
}
)

force_slash_deposit

Slash a deposit for an account that entered or extended safe-mode at a given historical block.

This can only be called while safe-mode is entered.

Emits a [Event::DepositSlashed] event on success. Errors with [Error::Entered] if safe-mode is entered.

Can only be called by the [Config::ForceDepositOrigin] origin.

Attributes

Name Type
account T::AccountId
block BlockNumberFor<T>

Python

call = substrate.compose_call(
    'SafeMode', 'force_slash_deposit', {
    'account': 'AccountId',
    'block': 'u32',
}
)

release_deposit

Permissionlessly release a deposit for an account that entered safe-mode at a given historical block.

The call can be completely disabled by setting [Config::ReleaseDelay] to None. This cannot be called while safe-mode is entered and not until [Config::ReleaseDelay] blocks have passed since safe-mode was entered.

Emits a [Event::DepositReleased] event on success. Errors with [Error::Entered] if the safe-mode is entered. Errors with [Error::CannotReleaseYet] if [Config::ReleaseDelay] block have not passed since safe-mode was entered. Errors with [Error::NoDeposit] if the payee has no reserved currency at the block specified.

Attributes

Name Type
account T::AccountId
block BlockNumberFor<T>

Python

call = substrate.compose_call(
    'SafeMode', 'release_deposit', {
    'account': 'AccountId',
    'block': 'u32',
}
)

Events


CannotDeposit

Could not hold funds for entering or extending the safe-mode.

This error comes from the underlying Currency.

Attributes

No attributes


CannotRelease

Could not release funds for entering or extending the safe-mode.

This error comes from the underlying Currency.

Attributes

No attributes


DepositPlaced

An account reserved funds for either entering or extending the safe-mode.

Attributes

Name Type Composition
account T::AccountId AccountId
amount BalanceOf<T> u64

DepositReleased

An account had a reserve released that was reserved.

Attributes

Name Type Composition
account T::AccountId AccountId
amount BalanceOf<T> u64

DepositSlashed

An account had reserve slashed that was reserved.

Attributes

Name Type Composition
account T::AccountId AccountId
amount BalanceOf<T> u64

Entered

The safe-mode was entered until inclusively this block.

Attributes

Name Type Composition
until BlockNumberFor<T> u32

Exited

Exited the safe-mode for a specific reason.

Attributes

Name Type Composition
reason ExitReason ('Timeout', 'Force')

Extended

The safe-mode was extended until inclusively this block.

Attributes

Name Type Composition
until BlockNumberFor<T> u32

Storage functions


Deposits

Holds the reserve that was taken from an account at a specific block number.

This helps governance to have an overview of outstanding deposits that should be returned or slashed.

Python

result = substrate.query(
    'SafeMode', 'Deposits', ['AccountId', 'u32']
)

Return value

'u64'

EnteredUntil

Contains the last block number that the safe-mode will remain entered in.

Set to None when safe-mode is exited.

Safe-mode is automatically exited when the current block number exceeds this value.

Python

result = substrate.query(
    'SafeMode', 'EnteredUntil', []
)

Return value

'u32'

Constants


EnterDepositAmount

The amount that will be reserved upon calling [Pallet::enter].

None disallows permissionlessly enabling the safe-mode and is a sane default.

Value

None

Python

constant = substrate.get_constant('SafeMode', 'EnterDepositAmount')

EnterDuration

For how many blocks the safe-mode will be entered by [Pallet::enter].

Value

0

Python

constant = substrate.get_constant('SafeMode', 'EnterDuration')

ExtendDepositAmount

The amount that will be reserved upon calling [Pallet::extend].

None disallows permissionlessly extending the safe-mode and is a sane default.

Value

None

Python

constant = substrate.get_constant('SafeMode', 'ExtendDepositAmount')

ExtendDuration

For how many blocks the safe-mode can be extended by each [Pallet::extend] call.

This does not impose a hard limit as the safe-mode can be extended multiple times.

Value

0

Python

constant = substrate.get_constant('SafeMode', 'ExtendDuration')

ReleaseDelay

The minimal duration a deposit will remain reserved after safe-mode is entered or extended, unless [Pallet::force_release_deposit] is successfully called sooner.

Every deposit is tied to a specific activation or extension, thus each deposit can be released independently after the delay for it has passed.

None disallows permissionlessly releasing the safe-mode deposits and is a sane default.

Value

None

Python

constant = substrate.get_constant('SafeMode', 'ReleaseDelay')

Errors


AlreadyDeposited

The account already has a deposit reserved and can therefore not enter or extend again.


CannotReleaseYet

This deposit cannot be released yet.


CurrencyError

An error from the underlying Currency.


Entered

The safe-mode is (already or still) entered.


Exited

The safe-mode is (already or still) exited.


NoDeposit

There is no balance reserved.


NotConfigured

This functionality of the pallet is disabled by the configuration.