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 2 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
165 changes: 89 additions & 76 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 = 5 * DOLLARS;
pub const FriendDepositFactor: Balance = 50 * CENTS;
pub const MaxFriends: u16 = 9;
pub const RecoveryDeposit: Balance = 5 * DOLLARS;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you decide on these parameters?

Copy link
Member Author

@nakul1010 nakul1010 Jun 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had taken reference from the frame config set, but after re-reviewing, I suggest setting one of the following configs defined below.

INTR Config based on KSM Config set

Current Market Price

1 KSM -> 25 USD 
1 INTR -> 0.0159 USD 
pub const ConfigDepositBase: Balance = 8 * Dollars; //0.0000000000125 USD

pub const FriendDepositFactor: Balance = 1 * Dollars; //0.00000000000125 USD

pub const MaxFriends: u16 = 9;

pub const RecoveryDeposit: Balance = 8 * Dollars; //0.0000000000125 USD

INTR Config based on Dollar, this

pub const ConfigDepositBase: Balance = 315 * Dollars; // if 1 INTR -> 0.0159 USD, this is equivalent to 5 Dollars

pub const FriendDepositFactor: Balance = 31 * Dollars; //this is equivalent to 0.5 Dollars

pub const MaxFriends: u16 = 9;

pub const RecoveryDeposit: Balance = 6300 * Dollars; // equivalent to 100 dollars, I recommend setting a larger value for the RecoveryDeposit compared to the ConfigDepositBase. 
// While many para chains set the RecoveryDeposit equal to the ConfigDepositBase, I suggest using a higher amount, 100 Dollars. 
// By increasing the RecoveryDeposit, we can ensure a more robust recovery process and mitigate the risk of unauthorized or malicious recoveries based on game theory.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Polkadot yet not have added the recovery pallet into the runtime.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense to me!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't those values very very high? We require 250 vINTR for governance proposals and these would require a lot more INTR to actually use this feature. So only very few people could use this.

What's the downside of setting this to much lower values so that you could set this up with say max 500 INTR?

Copy link
Member Author

@nakul1010 nakul1010 Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nud3l, I agree that we can reduce the value of ConfigDepositBase to 100 INTR to make it more accessible. However, it is important to keep the RecoveryDeposit at a sufficiently high level. This is because the RecoveryDeposit amount is refunded if the recovery process is successful.

If we set the RecoveryDeposit value too low, there is a risk that a malicious rescuer could attempt to recover the account, and if the account holder cancels the recovery process, the malicious rescuer would only lose a minimal amount due to the low RecoveryDeposit value.

It's worth noting that the RecoveryDeposit only needs to be reserved if the account recovery process is on and not when setting up the account recovery.


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 @@ -1190,82 +1208,76 @@ construct_runtime! {
NodeBlock = primitives::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 0,
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 1,
Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 2,
Utility: pallet_utility::{Pallet, Call, Event} = 3,
TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event<T>} = 4,
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 5,
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 6,
Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>} = 7,
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,

// # 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,

Escrow: escrow::{Pallet, Call, Storage, Event<T>} = 30,
EscrowAnnuity: annuity::<Instance1>::{Pallet, Call, Storage, Event<T>} = 31,
EscrowRewards: reward::<Instance1>::{Pallet, Storage, Event<T>} = 32,

VaultAnnuity: annuity::<Instance2>::{Pallet, Call, Storage, Event<T>} = 40,
VaultRewards: reward::<Instance2>::{Pallet, Storage, Event<T>} = 41,
VaultStaking: staking::{Pallet, Storage, Event<T>} = 42,
VaultCapacity: reward::<Instance3>::{Pallet, Storage, Event<T>} = 43,

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,
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>} = 82,
Aura: pallet_aura::{Pallet, Storage, Config<T>} = 83,
AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config} = 84,
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,
DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 93,

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,
DexSwapRouter: dex_swap_router::{Pallet, Call, Event<T>} = 103,
System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 0,
nakul1010 marked this conversation as resolved.
Show resolved Hide resolved
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 1,
Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 2,
Utility: pallet_utility::{Pallet, Call, Event} = 3,
TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event<T>} = 4,
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 5,
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 6,
Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>} = 7,
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,

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,

Escrow: escrow::{Pallet, Call, Storage, Event<T>} = 30,
EscrowAnnuity: annuity::<Instance1>::{Pallet, Call, Storage, Event<T>} = 31,
EscrowRewards: reward::<Instance1>::{Pallet, Storage, Event<T>} = 32,

VaultAnnuity: annuity::<Instance2>::{Pallet, Call, Storage, Event<T>} = 40,
VaultRewards: reward::<Instance2>::{Pallet, Storage, Event<T>} = 41,
VaultStaking: staking::{Pallet, Storage, Event<T>} = 42,
VaultCapacity: reward::<Instance3>::{Pallet, Storage, Event<T>} = 43,

Farming: farming::{Pallet, Call, Storage, Event<T>} = 44,
FarmingRewards: reward::<Instance4>::{Pallet, Storage, Event<T>} = 45,

BTCRelay: btc_relay::{Pallet, Call, Config<T>, Storage, Event<T>} = 50,

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,
Nomination: nomination::{Pallet, Call, Config, Storage, Event<T>} = 68,
ClientsInfo: clients_info::{Pallet, Call, Storage, Event<T>} = 69,

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,

Authorship: pallet_authorship::{Pallet, Storage} = 80,
CollatorSelection: collator_selection::{Pallet, Call, Storage, Event<T>, Config<T>} = 81,
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>} = 82,
Aura: pallet_aura::{Pallet, Storage, Config<T>} = 83,
AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config} = 84,
ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>} = 85,
ParachainInfo: parachain_info::{Pallet, Storage, Config} = 86,

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,
DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 93,

XTokens: orml_xtokens::{Pallet, Storage, Call, Event<T>} = 94,
UnknownTokens: orml_unknown_tokens::{Pallet, Storage, Event} = 95,

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,
DexSwapRouter: dex_swap_router::{Pallet, Call, Event<T>} = 103,
}
}

Expand Down Expand Up @@ -1351,6 +1363,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
Loading