Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add recovery pallet in runtime. #1105

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions parachain/runtime/interlay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pallet-multisig = { git = "https://github.com/paritytech/substrate", branch = "p
pallet-preimage = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
pallet-identity = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
pallet-proxy = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
pallet-recovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }

frame-try-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false, optional = true }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
Expand Down Expand Up @@ -177,6 +178,7 @@ std = [
"pallet-preimage/std",
"pallet-identity/std",
"pallet-proxy/std",
"pallet-recovery/std",

"frame-system-rpc-runtime-api/std",
"pallet-transaction-payment-rpc-runtime-api/std",
Expand Down Expand Up @@ -270,6 +272,7 @@ runtime-benchmarks = [
"pallet-multisig/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-recovery/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
Expand Down Expand Up @@ -318,6 +321,7 @@ try-runtime = [
"pallet-multisig/try-runtime",
"pallet-identity/try-runtime",
"pallet-proxy/try-runtime",
"pallet-recovery/try-runtime",
"pallet-sudo/try-runtime",

"currency/try-runtime",
Expand Down
31 changes: 21 additions & 10 deletions parachain/runtime/interlay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,24 @@ impl pallet_proxy::Config for Runtime {
type AnnouncementDepositFactor = AnnouncementDepositFactor;
}

parameter_types! {
pub const ConfigDepositBase: Balance = 100 * DOLLARS;
pub const FriendDepositFactor: Balance = 31 * DOLLARS;
pub const MaxFriends: u16 = 9;
pub const RecoveryDeposit: Balance = 6300 * DOLLARS;
}

impl pallet_recovery::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_recovery::WeightInfo<Runtime>;
type RuntimeCall = RuntimeCall;
type Currency = NativeCurrency;
type ConfigDepositBase = ConfigDepositBase;
type FriendDepositFactor = FriendDepositFactor;
type MaxFriends = MaxFriends;
type RecoveryDeposit = RecoveryDeposit;
}

impl vault_registry::Config for Runtime {
type PalletId = VaultRegistryPalletId;
type RuntimeEvent = RuntimeEvent;
Expand Down Expand Up @@ -1201,14 +1219,14 @@ construct_runtime! {
Identity: pallet_identity::{Pallet, Call, Storage, Event<T>} = 8,
Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>} = 9,
TxPause: tx_pause::{Pallet, Call, Storage, Event<T>} = 10,
Recovery: pallet_recovery::{Pallet, Call, Storage, Event<T>} = 11,

// # Tokens & Balances
Currency: currency::{Pallet} = 20,
Tokens: orml_tokens::{Pallet, Call, Storage, Config<T>, Event<T>} = 21,
Supply: supply::{Pallet, Storage, Call, Event<T>, Config<T>} = 22,
Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 23,
AssetRegistry: orml_asset_registry::{Pallet, Storage, Call, Event<T>, Config<T>} = 24,
MultiTransactionPayment: multi_transaction_payment::{Pallet, Call, Storage} = 25,
MultiTransactionPayment: multi_transaction_payment::{Pallet, Call, Storage} = 25,

Escrow: escrow::{Pallet, Call, Storage, Event<T>} = 30,
EscrowAnnuity: annuity::<Instance1>::{Pallet, Call, Storage, Event<T>} = 31,
Expand All @@ -1222,27 +1240,21 @@ construct_runtime! {
Farming: farming::{Pallet, Call, Storage, Event<T>} = 44,
FarmingRewards: reward::<Instance4>::{Pallet, Storage, Event<T>} = 45,

// # Bitcoin SPV
BTCRelay: btc_relay::{Pallet, Call, Config<T>, Storage, Event<T>} = 50,
// Relay: 51

// # Operational
Security: security::{Pallet, Call, Config, Storage, Event<T>} = 60,
VaultRegistry: vault_registry::{Pallet, Call, Config<T>, Storage, Event<T>, ValidateUnsigned} = 61,
Oracle: oracle::{Pallet, Call, Config<T>, Storage, Event<T>} = 62,
Issue: issue::{Pallet, Call, Config<T>, Storage, Event<T>} = 63,
Redeem: redeem::{Pallet, Call, Config<T>, Storage, Event<T>} = 64,
Replace: replace::{Pallet, Call, Config<T>, Storage, Event<T>} = 65,
Fee: fee::{Pallet, Call, Config<T>, Storage} = 66,
// Refund: 67
Nomination: nomination::{Pallet, Call, Config, Storage, Event<T>} = 68,
ClientsInfo: clients_info::{Pallet, Call, Storage, Event<T>} = 69,

// # Governance
Democracy: democracy::{Pallet, Call, Storage, Config<T>, Event<T>} = 70,
TechnicalCommittee: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>} = 71,
TechnicalMembership: pallet_membership::{Pallet, Call, Storage, Event<T>, Config<T>} = 72,
// Treasury: 73

Authorship: pallet_authorship::{Pallet, Storage} = 80,
CollatorSelection: collator_selection::{Pallet, Call, Storage, Event<T>, Config<T>} = 81,
Expand All @@ -1252,7 +1264,6 @@ construct_runtime! {
ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>} = 85,
ParachainInfo: parachain_info::{Pallet, Storage, Config} = 86,

// # XCM Helpers
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 90,
PolkadotXcm: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin, Config} = 91,
CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 92,
Expand All @@ -1261,7 +1272,6 @@ construct_runtime! {
XTokens: orml_xtokens::{Pallet, Storage, Call, Event<T>} = 94,
UnknownTokens: orml_unknown_tokens::{Pallet, Storage, Event} = 95,

// # Lending & AMM
Loans: loans::{Pallet, Call, Storage, Event<T>, Config} = 100,
DexGeneral: dex_general::{Pallet, Call, Storage, Event<T>} = 101,
DexStable: dex_stable::{Pallet, Call, Storage, Event<T>} = 102,
Expand Down Expand Up @@ -1351,6 +1361,7 @@ mod benches {
[pallet_multisig, Multisig]
[pallet_preimage, Preimage]
[pallet_proxy, Proxy]
[pallet_recovery,Recovery]
[pallet_scheduler, Scheduler]
[pallet_timestamp, Timestamp]
[pallet_utility, Utility]
Expand Down
1 change: 1 addition & 0 deletions parachain/runtime/interlay/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub mod pallet_membership;
pub mod pallet_multisig;
pub mod pallet_preimage;
pub mod pallet_proxy;
pub mod pallet_recovery;
pub mod pallet_scheduler;
pub mod pallet_timestamp;
pub mod pallet_utility;
Expand Down
178 changes: 178 additions & 0 deletions parachain/runtime/interlay/src/weights/pallet_recovery.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@

//! Autogenerated weights for `pallet_recovery`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-06-26, STEPS: `50`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `Nakul`, CPU: `<UNKNOWN>`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("interlay-dev"), DB CACHE: 1024

// Executed Command:
// ./target/release/interbtc-parachain
// benchmark
// pallet
// --pallet
// pallet_recovery
// --extrinsic
// *
// --chain
// interlay-dev
// --execution=wasm
// --wasm-execution=compiled
// --steps
// 50
// --repeat
// 10
// --output
// weights.rs

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]

use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData;

/// Weight functions for `pallet_recovery`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_recovery::WeightInfo for WeightInfo<T> {
/// Storage: Recovery Proxy (r:1 w:0)
/// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen)
fn as_recovered() -> Weight {
// Proof Size summary in bytes:
// Measured: `111`
// Estimated: `3545`
// Minimum execution time: 9_000_000 picoseconds.
Weight::from_parts(9_000_000, 0)
.saturating_add(Weight::from_parts(0, 3545))
.saturating_add(T::DbWeight::get().reads(1))
}
/// Storage: Recovery Proxy (r:0 w:1)
/// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen)
fn set_recovered() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 8_000_000 picoseconds.
Weight::from_parts(9_000_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Recovery Recoverable (r:1 w:1)
/// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen)
/// Storage: Tokens Accounts (r:1 w:1)
/// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen)
/// The range of component `n` is `[1, 9]`.
fn create_recovery(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `334 + n * (27 ±0)`
// Estimated: `7396`
// Minimum execution time: 25_000_000 picoseconds.
Weight::from_parts(25_772_388, 0)
.saturating_add(Weight::from_parts(0, 7396))
// Standard Error: 9_460
.saturating_add(Weight::from_parts(112_594, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: Recovery Recoverable (r:1 w:0)
/// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen)
/// Storage: Recovery ActiveRecoveries (r:1 w:1)
/// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen)
/// Storage: Tokens Accounts (r:1 w:1)
/// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen)
fn initiate_recovery() -> Weight {
// Proof Size summary in bytes:
// Measured: `689`
// Estimated: `11250`
// Minimum execution time: 31_000_000 picoseconds.
Weight::from_parts(32_000_000, 0)
.saturating_add(Weight::from_parts(0, 11250))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: Recovery Recoverable (r:1 w:0)
/// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen)
/// Storage: Recovery ActiveRecoveries (r:1 w:1)
/// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen)
/// The range of component `n` is `[1, 9]`.
fn vouch_recovery(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `190 + n * (64 ±0)`
// Estimated: `7670`
// Minimum execution time: 16_000_000 picoseconds.
Weight::from_parts(17_310_945, 0)
.saturating_add(Weight::from_parts(0, 7670))
// Standard Error: 12_247
.saturating_add(Weight::from_parts(76_001, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Recovery Recoverable (r:1 w:0)
/// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen)
/// Storage: Recovery ActiveRecoveries (r:1 w:0)
/// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen)
/// Storage: Recovery Proxy (r:1 w:1)
/// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen)
/// The range of component `n` is `[1, 9]`.
fn claim_recovery(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `222 + n * (64 ±0)`
// Estimated: `11215`
// Minimum execution time: 20_000_000 picoseconds.
Weight::from_parts(20_687_810, 0)
.saturating_add(Weight::from_parts(0, 11215))
// Standard Error: 8_550
.saturating_add(Weight::from_parts(75_150, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Recovery ActiveRecoveries (r:1 w:1)
/// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen)
/// Storage: Tokens Accounts (r:2 w:2)
/// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen)
/// The range of component `n` is `[1, 9]`.
fn close_recovery(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `612 + n * (59 ±0)`
// Estimated: `10024`
// Minimum execution time: 40_000_000 picoseconds.
Weight::from_parts(40_937_810, 0)
.saturating_add(Weight::from_parts(0, 10024))
// Standard Error: 13_523
.saturating_add(Weight::from_parts(215_501, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: Recovery ActiveRecoveries (r:1 w:0)
/// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen)
/// Storage: Recovery Recoverable (r:1 w:1)
/// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen)
/// Storage: Tokens Accounts (r:1 w:1)
/// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen)
/// The range of component `n` is `[1, 9]`.
fn remove_recovery(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `465 + n * (59 ±0)`
// Estimated: `11250`
// Minimum execution time: 27_000_000 picoseconds.
Weight::from_parts(27_750_621, 0)
.saturating_add(Weight::from_parts(0, 11250))
// Standard Error: 7_853
.saturating_add(Weight::from_parts(56_002, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: Recovery Proxy (r:1 w:1)
/// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen)
fn cancel_recovered() -> Weight {
// Proof Size summary in bytes:
// Measured: `111`
// Estimated: `3545`
// Minimum execution time: 10_000_000 picoseconds.
Weight::from_parts(10_000_000, 0)
.saturating_add(Weight::from_parts(0, 3545))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
}
8 changes: 6 additions & 2 deletions parachain/runtime/kintsugi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pallet-multisig = { git = "https://github.com/paritytech/substrate", branch = "p
pallet-preimage = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
pallet-identity = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
pallet-proxy = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
pallet-recovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }

frame-try-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false, optional = true }
Expand Down Expand Up @@ -182,7 +183,8 @@ std = [
"pallet-preimage/std",
"pallet-identity/std",
"pallet-proxy/std",
"pallet-sudo/std",
"pallet-recovery/std",
"pallet-sudo/std",

"frame-system-rpc-runtime-api/std",
"pallet-transaction-payment-rpc-runtime-api/std",
Expand Down Expand Up @@ -277,6 +279,7 @@ runtime-benchmarks = [
"pallet-multisig/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-recovery/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
Expand Down Expand Up @@ -324,7 +327,8 @@ try-runtime = [
"pallet-multisig/try-runtime",
"pallet-identity/try-runtime",
"pallet-proxy/try-runtime",
"pallet-sudo/try-runtime",
"pallet-recovery/try-runtime",
"pallet-sudo/try-runtime",
"currency/try-runtime",
"orml-tokens/try-runtime",
"supply/try-runtime",
Expand Down
1 change: 1 addition & 0 deletions parachain/runtime/kintsugi/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub mod currency {

// https://github.com/paritytech/polkadot/blob/c4ee9d463adccfa3bf436433e3e26d0de5a4abbc/runtime/kusama/src/constants.rs#L18
pub const UNITS: Balance = NATIVE_TOKEN_ID.one();
pub const DOLLARS: Balance = UNITS; // 1_000_000_000_000
pub const CENTS: Balance = UNITS / 30_000;
pub const GRAND: Balance = CENTS * 100_000;
pub const MILLICENTS: Balance = CENTS / 1_000;
Expand Down
Loading