Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add salp multisig account to spec&runtime migration
  • Loading branch information
yrong committed Dec 17, 2021
commit 9e0cdd35cc72c1faf00aceb32a4c1fe50400c99b
27 changes: 25 additions & 2 deletions node/service/src/chain_spec/asgard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use asgard_runtime::{
constants::currency::DOLLARS, AccountId, AuraId, Balance, BalancesConfig, BancorConfig,
BlockNumber, CollatorSelectionConfig, CouncilConfig, DemocracyConfig, GenesisConfig,
IndicesConfig, MinterRewardConfig, ParachainInfoConfig, PolkadotXcmConfig, SS58Prefix,
SessionConfig, SudoConfig, SystemConfig, TechnicalCommitteeConfig, TokensConfig, VestingConfig,
VtokenMintConfig, WASM_BINARY,
SalpConfig, SalpLiteConfig, SessionConfig, SudoConfig, SystemConfig, TechnicalCommitteeConfig,
TokensConfig, VestingConfig, VtokenMintConfig, WASM_BINARY,
};
use bifrost_runtime_common::constants::time::*;
use cumulus_primitives_core::ParaId;
Expand Down Expand Up @@ -81,6 +81,8 @@ pub fn asgard_genesis(
balances: Vec<(AccountId, Balance)>,
vestings: Vec<(AccountId, BlockNumber, BlockNumber, Balance)>,
tokens: Vec<(AccountId, CurrencyId, Balance)>,
salp_multisig_key: AccountId,
salp_lite_multisig_key_salp: AccountId,
) -> GenesisConfig {
GenesisConfig {
system: SystemConfig {
Expand Down Expand Up @@ -154,6 +156,8 @@ pub fn asgard_genesis(
],
},
polkadot_xcm: PolkadotXcmConfig { safe_xcm_version: Some(2) },
salp: SalpConfig { initial_multisig_account: Some(salp_multisig_key) },
salp_lite: SalpLiteConfig { initial_multisig_account: Some(salp_lite_multisig_key_salp) },
}
}

Expand Down Expand Up @@ -183,6 +187,10 @@ fn development_config_genesis(id: ParaId) -> GenesisConfig {
]
})
.collect();
let salp_multisig: AccountId =
hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into();
let salp_lite_multisig: AccountId =
hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into();

asgard_genesis(
vec![(
Expand All @@ -194,6 +202,8 @@ fn development_config_genesis(id: ParaId) -> GenesisConfig {
balances,
vestings,
tokens,
salp_multisig,
salp_lite_multisig,
)
}

Expand Down Expand Up @@ -260,6 +270,11 @@ fn local_config_genesis(id: ParaId) -> GenesisConfig {
})
.collect();

let salp_multisig: AccountId =
hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into();
let salp_lite_multisig: AccountId =
hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into();

asgard_genesis(
vec![
(
Expand All @@ -273,6 +288,8 @@ fn local_config_genesis(id: ParaId) -> GenesisConfig {
balances,
vestings,
tokens,
salp_multisig,
salp_lite_multisig,
)
}

Expand Down Expand Up @@ -356,6 +373,10 @@ fn asgard_config_genesis(id: ParaId) -> GenesisConfig {
]
})
.collect();
let salp_multisig: AccountId =
hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into();
let salp_lite_multisig: AccountId =
hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into();

asgard_genesis(
invulnerables,
Expand All @@ -364,6 +385,8 @@ fn asgard_config_genesis(id: ParaId) -> GenesisConfig {
balances,
vesting_configs.into_iter().flat_map(|vc| vc.vesting).collect(),
tokens,
salp_multisig,
salp_lite_multisig,
)
}

Expand Down
30 changes: 28 additions & 2 deletions node/service/src/chain_spec/bifrost_kusama.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ use std::{
use bifrost_kusama_runtime::{
AccountId, AuraId, Balance, BalancesConfig, BlockNumber, CollatorSelectionConfig,
CouncilConfig, CouncilMembershipConfig, DemocracyConfig, GenesisConfig, IndicesConfig,
ParachainInfoConfig, PolkadotXcmConfig, SS58Prefix, SessionConfig, SystemConfig,
TechnicalCommitteeConfig, TechnicalMembershipConfig, TokensConfig, VestingConfig, WASM_BINARY,
ParachainInfoConfig, PolkadotXcmConfig, SS58Prefix, SalpConfig, SalpLiteConfig, SessionConfig,
SystemConfig, TechnicalCommitteeConfig, TechnicalMembershipConfig, TokensConfig, VestingConfig,
WASM_BINARY,
};
use bifrost_runtime_common::dollar;
use cumulus_primitives_core::ParaId;
Expand Down Expand Up @@ -90,6 +91,8 @@ pub fn bifrost_genesis(
tokens: Vec<(AccountId, CurrencyId, Balance)>,
council_membership: Vec<AccountId>,
technical_committee_membership: Vec<AccountId>,
salp_multisig_key: AccountId,
salp_lite_multisig_key_salp: AccountId,
) -> GenesisConfig {
GenesisConfig {
system: SystemConfig {
Expand Down Expand Up @@ -138,6 +141,8 @@ pub fn bifrost_genesis(
vesting: VestingConfig { vesting: vestings },
tokens: TokensConfig { balances: tokens },
polkadot_xcm: PolkadotXcmConfig { safe_xcm_version: Some(2) },
salp: SalpConfig { initial_multisig_account: Some(salp_multisig_key) },
salp_lite: SalpLiteConfig { initial_multisig_account: Some(salp_lite_multisig_key_salp) },
}
}

Expand Down Expand Up @@ -168,6 +173,12 @@ fn development_config_genesis(id: ParaId) -> GenesisConfig {
let council_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let technical_committee_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];

let salp_multisig: AccountId =
hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into();

let salp_lite_multisig: AccountId =
hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into();

bifrost_genesis(
vec![(
get_account_id_from_seed::<sr25519::Public>("Alice"),
Expand All @@ -179,6 +190,8 @@ fn development_config_genesis(id: ParaId) -> GenesisConfig {
tokens,
council_membership,
technical_committee_membership,
salp_multisig,
salp_lite_multisig,
)
}

Expand Down Expand Up @@ -244,6 +257,10 @@ fn local_config_genesis(id: ParaId) -> GenesisConfig {

let council_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let technical_committee_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let salp_multisig: AccountId =
hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into();
let salp_lite_multisig: AccountId =
hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into();

bifrost_genesis(
vec![
Expand All @@ -259,6 +276,8 @@ fn local_config_genesis(id: ParaId) -> GenesisConfig {
tokens,
council_membership,
technical_committee_membership,
salp_multisig,
salp_lite_multisig,
)
}

Expand Down Expand Up @@ -358,6 +377,11 @@ fn bifrost_config_genesis(id: ParaId) -> GenesisConfig {
let vesting_configs: Vec<VestingConfig> =
config_from_json_files(exe_dir.join("res/genesis_config/vesting")).unwrap();

let salp_multisig: AccountId =
hex!["e4da05f08e89bf6c43260d96f26fffcfc7deae5b465da08669a9d008e64c2c63"].into();
let salp_lite_multisig: AccountId =
hex!["e4f78719c654cd8e8ac1375c447b7a80f9476cfe6505ea401c4b15bd6b967c93"].into();

use sp_core::sp_std::collections::btree_map::BTreeMap;
bifrost_genesis(
invulnerables,
Expand All @@ -367,6 +391,8 @@ fn bifrost_config_genesis(id: ParaId) -> GenesisConfig {
vec![], // tokens
vec![], // council membership
vec![], // technical committee membership
salp_multisig,
salp_lite_multisig,
)
}

Expand Down
29 changes: 27 additions & 2 deletions pallets/salp-lite/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,20 +257,41 @@ pub mod pallet {
ValueQuery,
>;

#[pallet::genesis_config]
pub struct GenesisConfig<T: Config> {
pub initial_multisig_account: Option<AccountIdOf<T>>,
}

#[cfg(feature = "std")]
impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
Self { initial_multisig_account: None }
}
}

#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
fn build(&self) {
if let Some(ref key) = self.initial_multisig_account {
MultisigConfirmAccount::<T>::put(key)
}
}
}

#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::weight((
0,
DispatchClass::Normal,
Pays::No
))]
pub fn set_multisig_account(
pub fn set_multisig_confirm_account(
origin: OriginFor<T>,
account: AccountIdOf<T>,
) -> DispatchResult {
T::EnsureConfirmAsGovernance::ensure_origin(origin)?;

MultisigConfirmAccount::<T>::put(account);
Self::set_multisig_account(account);

Ok(())
}
Expand Down Expand Up @@ -702,6 +723,10 @@ pub mod pallet {
}

impl<T: Config> Pallet<T> {
/// set multisig account
pub fn set_multisig_account(account: AccountIdOf<T>) {
MultisigConfirmAccount::<T>::put(account);
}
pub fn fund_account_id(index: ParaId) -> T::AccountId {
T::PalletId::get().into_sub_account(index)
}
Expand Down
29 changes: 27 additions & 2 deletions pallets/salp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,20 +332,41 @@ pub mod pallet {
#[pallet::getter(fn redeem_pool)]
pub(super) type RedeemPool<T: Config> = StorageValue<_, BalanceOf<T>, ValueQuery>;

#[pallet::genesis_config]
pub struct GenesisConfig<T: Config> {
pub initial_multisig_account: Option<AccountIdOf<T>>,
}

#[cfg(feature = "std")]
impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
Self { initial_multisig_account: None }
}
}

#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
fn build(&self) {
if let Some(ref key) = self.initial_multisig_account {
MultisigConfirmAccount::<T>::put(key)
}
}
}

#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::weight((
0,
DispatchClass::Normal,
Pays::No
))]
pub fn set_multisig_account(
pub fn set_multisig_confirm_account(
origin: OriginFor<T>,
account: AccountIdOf<T>,
) -> DispatchResult {
T::EnsureConfirmAsGovernance::ensure_origin(origin)?;

MultisigConfirmAccount::<T>::put(account);
Self::set_multisig_account(account);

Ok(())
}
Expand Down Expand Up @@ -1030,6 +1051,10 @@ pub mod pallet {
}

impl<T: Config> Pallet<T> {
/// set multisig account
pub fn set_multisig_account(account: AccountIdOf<T>) {
MultisigConfirmAccount::<T>::put(account);
}
/// Check if the vsBond is `past` the redeemable date
pub(crate) fn is_expired(block: BlockNumberFor<T>, last_slot: LeasePeriod) -> bool {
let block_begin_redeem = Self::block_end_of_lease_period_index(last_slot);
Expand Down
4 changes: 2 additions & 2 deletions runtime/asgard/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1665,13 +1665,13 @@ construct_runtime! {
FlexibleFee: bifrost_flexible_fee::{Pallet, Call, Storage, Event<T>} = 100,
VtokenMint: bifrost_vtoken_mint::{Pallet, Call, Storage, Event<T>, Config<T>} = 101,
MinterReward: bifrost_minter_reward::{Pallet, Call, Storage, Event<T>, Config<T>} = 102,
Salp: bifrost_salp::{Pallet, Call, Storage, Event<T>} = 105,
Salp: bifrost_salp::{Pallet, Call, Storage, Event<T>,Config<T>} = 105,
Bancor: bifrost_bancor::{Pallet, Call, Storage, Event<T>, Config<T>} = 106,
LiquidityMiningDOT: bifrost_liquidity_mining::<Instance2>::{Pallet, Call, Storage, Event<T>} = 107,
LiquidityMining: bifrost_liquidity_mining::<Instance1>::{Pallet, Call, Storage, Event<T>} = 108,
TokenIssuer: bifrost_token_issuer::{Pallet, Call, Storage, Event<T>} = 109,
LighteningRedeem: bifrost_lightening_redeem::{Pallet, Call, Storage, Event<T>} = 110,
SalpLite: bifrost_salp_lite::{Pallet, Call, Storage, Event<T>} = 111,
SalpLite: bifrost_salp_lite::{Pallet, Call, Storage, Event<T>, Config<T>} = 111,
CallSwitchgear: bifrost_call_switchgear::{Pallet, Storage, Call, Event<T>} = 112,
VSBondAuction: bifrost_vsbond_auction::{Pallet, Call, Storage, Event<T>} = 113,
}
Expand Down
8 changes: 5 additions & 3 deletions runtime/bifrost/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1634,12 +1634,12 @@ construct_runtime! {

// Bifrost modules
FlexibleFee: bifrost_flexible_fee::{Pallet, Call, Storage, Event<T>} = 100,
Salp: bifrost_salp::{Pallet, Call, Storage, Event<T>} = 105,
Salp: bifrost_salp::{Pallet, Call, Storage, Event<T>, Config<T>} = 105,
LiquidityMiningDOT: bifrost_liquidity_mining::<Instance2>::{Pallet, Call, Storage, Event<T>} = 107,
LiquidityMining: bifrost_liquidity_mining::<Instance1>::{Pallet, Call, Storage, Event<T>} = 108,
TokenIssuer: bifrost_token_issuer::{Pallet, Call, Storage, Event<T>} = 109,
LighteningRedeem: bifrost_lightening_redeem::{Pallet, Call, Storage, Event<T>} = 110,
SalpLite: bifrost_salp_lite::{Pallet, Call, Storage, Event<T>} = 111,
SalpLite: bifrost_salp_lite::{Pallet, Call, Storage, Event<T>, Config<T>} = 111,
CallSwitchgear: bifrost_call_switchgear::{Pallet, Storage, Call, Event<T>} = 112,
VSBondAuction: bifrost_vsbond_auction::{Pallet, Call, Storage, Event<T>} = 113,
}
Expand Down Expand Up @@ -1684,7 +1684,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPallets,
(),
CustomOnRuntimeUpgrade,
>;

impl_runtime_apis! {
Expand Down Expand Up @@ -1981,6 +1981,8 @@ impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
fn on_runtime_upgrade() -> Weight {
log::info!("Bifrost `on_runtime_upgrade`...");
log::info!("Bifrost `on_runtime_upgrade finished`");
Salp::set_multisig_account(ConfirmMuitiSigAccount::get());
SalpLite::set_multisig_account(PolkaConfirmAsMultiSig::get());
RocksDbWeight::get().writes(1)
}
}
Expand Down