diff --git a/pallets/salp/src/lib.rs b/pallets/salp/src/lib.rs index e4d8e643b..428fa6240 100644 --- a/pallets/salp/src/lib.rs +++ b/pallets/salp/src/lib.rs @@ -80,8 +80,6 @@ impl Default for FundStatus { #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)] #[codec(dumb_trait_bound)] pub struct FundInfo { - /// The amount of deposit placed. - deposit: Balance, /// The total amount raised. raised: Balance, /// A hard-cap on the amount that may be contributed. @@ -98,18 +96,11 @@ pub struct FundInfo { status: FundStatus, } -#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)] -#[codec(dumb_trait_bound)] -pub struct ContributionMemoInfo { - index: TrieIndex, -} - #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, Copy)] pub enum ContributionStatus { Idle, Refunded, Unlocked, - Refunding, Contributing(BalanceOf), } @@ -146,7 +137,6 @@ pub mod pallet { pallet_prelude::{storage::child, *}, sp_runtime::traits::{AccountIdConversion, CheckedAdd, Hash, Saturating, Zero}, storage::ChildTriePrefixIterator, - weights::WeightToFeePolynomial, PalletId, }; use frame_system::pallet_prelude::*; @@ -171,9 +161,6 @@ pub mod pallet { #[pallet::constant] type PalletId: Get; - /// The amount to be held on deposit by the depositor of a crowdloan. - type SubmissionDeposit: Get>; - /// The minimum amount that may be contributed into a crowdloan. Should almost certainly be /// at least ExistentialDeposit. #[pallet::constant] @@ -182,9 +169,6 @@ pub mod pallet { #[pallet::constant] type RelayChainToken: Get; - #[pallet::constant] - type DepositToken: Get; - /// The number of blocks over which a single period lasts. #[pallet::constant] type LeasePeriod: Get>; @@ -214,11 +198,6 @@ pub mod pallet { type BancorPool: BancorHandler>; - type ExecuteXcmOrigin: EnsureOrigin< - ::Origin, - Success = MultiLocation, - >; - type EnsureConfirmAsMultiSig: EnsureOrigin<::Origin>; type BifrostXcmExecutor: BifrostXcmExecutor; @@ -232,9 +211,6 @@ pub mod pallet { /// Parachain Id type SelfParaId: Get; - /// Weight to Fee calculator - type WeightToFee: WeightToFeePolynomial>; - /// Xcm weight #[pallet::constant] type BaseXcmWeight: Get; @@ -242,15 +218,9 @@ pub mod pallet { #[pallet::constant] type ContributionWeight: Get; - #[pallet::constant] - type WithdrawWeight: Get; - #[pallet::constant] type AddProxyWeight: Get; - #[pallet::constant] - type RemoveProxyWeight: Get; - /// The interface to Cross-chain transfer. type XcmTransfer: XcmTransfer, BalanceOf, CurrencyId>; @@ -320,8 +290,6 @@ pub mod pallet { InvalidContributionStatus, /// Contributions exceed maximum amount. CapExceeded, - /// The origin of this call is invalid. - UnauthorizedAccount, /// The fund has been registered. FundAlreadyCreated, /// Crosschain xcm failed @@ -338,12 +306,8 @@ pub mod pallet { UnRedeemableNow, /// Dont have enough vsToken/vsBond to redeem NotEnoughFreeAssetsToRedeem, - /// Dont have enough vsToken/vsBond to unlock when redeem failed - NotEnoughReservedAssetsToUnlockWhenRedeemFailed, /// Don't have enough token to redeem by users NotEnoughBalanceInRedeemPool, - /// Invalid redeem status - InvalidRedeemStatus, } /// Tracker for the next available fund index @@ -462,6 +426,7 @@ pub mod pallet { /// Unlock the reserved vsToken/vsBond after fund success #[pallet::weight(T::WeightInfo::unlock())] + #[transactional] pub fn unlock( _origin: OriginFor, who: AccountIdOf, @@ -505,6 +470,7 @@ pub mod pallet { DispatchClass::Normal, Pays::No ))] + #[transactional] pub fn batch_unlock( origin: OriginFor, #[pallet::compact] index: ParaId, @@ -580,12 +546,9 @@ pub mod pallet { .ok_or(Error::::FirstSlotTooFarInFuture)?; ensure!(last_slot <= last_slot_limit, Error::::LastSlotTooFarInFuture); - let deposit = T::SubmissionDeposit::get(); - Funds::::insert( index, Some(FundInfo { - deposit, raised: Zero::zero(), cap, first_slot, @@ -658,6 +621,7 @@ pub mod pallet { DispatchClass::Normal, Pays::No ))] + #[transactional] pub fn confirm_contribute( origin: OriginFor, who: AccountIdOf, @@ -875,6 +839,7 @@ pub mod pallet { DispatchClass::Normal, Pays::No ))] + #[transactional] pub fn dissolve(origin: OriginFor, #[pallet::compact] index: ParaId) -> DispatchResult { T::EnsureConfirmAsMultiSig::ensure_origin(origin)?; diff --git a/pallets/salp/src/mock.rs b/pallets/salp/src/mock.rs index 4c5679d2f..fcc098a6e 100644 --- a/pallets/salp/src/mock.rs +++ b/pallets/salp/src/mock.rs @@ -39,7 +39,6 @@ use xcm::{ v0::{MultiLocation, NetworkId}, DoubleEncoded, }; -use xcm_builder::{EnsureXcmOrigin, SignedToAccountId32}; use xcm_support::{BifrostXcmExecutor, Weight}; use crate as salp; @@ -194,7 +193,6 @@ pub fn create_x2_parachain_multilocation(_index: u16) -> MultiLocation { } parameter_types! { - pub const SubmissionDeposit: u32 = 1; pub const MinContribution: Balance = 10; pub const BifrostCrowdloanId: PalletId = PalletId(*b"bf/salp#"); pub const RemoveKeysLimit: u32 = 50; @@ -203,13 +201,10 @@ parameter_types! { pub const VSBondValidPeriod: BlockNumber = 30 * DAYS; pub const ReleaseCycle: BlockNumber = 1 * DAYS; pub const ReleaseRatio: Percent = Percent::from_percent(50); - pub const DepositTokenType: CurrencyId = CurrencyId::Token(TokenSymbol::ASG); pub const XcmTransferOrigin: TransferOriginType = TransferOriginType::FromRelayChain; pub BaseXcmWeight:u64 = 1_000_000_000 as u64; pub ContributionWeight:u64 = 1_000_000_000 as u64; - pub WithdrawWeight:u64 = 1_000_000_000 as u64; pub AddProxyWeight:u64 = 1_000_000_000 as u64; - pub RemoveProxyWeight:u64 = 1_000_000_000 as u64; pub const SelfParaId: u32 = 2001; pub PrimaryAccount: AccountId = ALICE; pub ConfirmMuitiSigAccount: AccountId = Multisig::multi_account_id(&vec![ @@ -226,8 +221,6 @@ parameter_types! { pub const AnyNetwork: NetworkId = NetworkId::Any; } -type LocalOriginToLocation = (SignedToAccountId32,); - pub struct EnsureConfirmAsMultiSig; impl EnsureOrigin for EnsureConfirmAsMultiSig { type Success = AccountId; @@ -298,9 +291,7 @@ impl XcmTransfer for MockXTokens { impl salp::Config for Test { type BancorPool = Bancor; type BifrostXcmExecutor = MockXcmExecutor; - type DepositToken = NativeCurrencyId; type Event = Event; - type ExecuteXcmOrigin = EnsureXcmOrigin; type LeasePeriod = LeasePeriod; type MinContribution = MinContribution; type MultiCurrency = Tokens; @@ -310,18 +301,14 @@ impl salp::Config for Test { type ReleaseRatio = ReleaseRatio; type RemoveKeysLimit = RemoveKeysLimit; type SlotLength = SlotLength; - type SubmissionDeposit = SubmissionDeposit; type VSBondValidPeriod = VSBondValidPeriod; type XcmTransferOrigin = XcmTransferOrigin; type WeightInfo = SalpWeightInfo; type SelfParaId = SelfParaId; type BaseXcmWeight = BaseXcmWeight; type ContributionWeight = ContributionWeight; - type WithdrawWeight = WithdrawWeight; type EnsureConfirmAsMultiSig = EnsureConfirmAsMultiSig; - type WeightToFee = WeightToFee; type AddProxyWeight = AddProxyWeight; - type RemoveProxyWeight = RemoveProxyWeight; type XcmTransfer = MockXTokens; type SovereignSubAccountLocation = RelaychainSovereignSubAccount; type TransactProxyType = SalpTransactProxyType; diff --git a/runtime/asgard/src/lib.rs b/runtime/asgard/src/lib.rs index 9c69dd462..b396b8b3d 100644 --- a/runtime/asgard/src/lib.rs +++ b/runtime/asgard/src/lib.rs @@ -106,7 +106,7 @@ use xcm_builder::{ EnsureXcmOrigin, FixedRateOfConcreteFungible, FixedWeightBounds, IsConcrete, LocationInverter, ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit, UsingComponents, + SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit, }; use xcm_executor::{Config, XcmExecutor}; use xcm_support::{BifrostCurrencyAdapter, BifrostXcmAdaptor}; @@ -1011,7 +1011,6 @@ impl EnsureOrigin for EnsureConfirmAsMultiSig { } parameter_types! { - pub const SubmissionDeposit: Balance = 100 * DOLLARS; pub const MinContribution: Balance = 1 * DOLLARS; pub const BifrostCrowdloanId: PalletId = PalletId(*b"bf/salp#"); pub const RemoveKeysLimit: u32 = 500; @@ -1023,9 +1022,7 @@ parameter_types! { pub const XcmTransferOrigin: TransferOriginType = TransferOriginType::FromRelayChain; pub XcmWeight: XcmBaseWeight = XCM_WEIGHT.into(); pub ContributionWeight:XcmBaseWeight = XCM_WEIGHT.into(); - pub WithdrawWeight:XcmBaseWeight = XCM_WEIGHT.into(); pub AddProxyWeight:XcmBaseWeight = XCM_WEIGHT.into(); - pub RemoveProxyWeight:XcmBaseWeight = XCM_WEIGHT.into(); pub ConfirmMuitiSigAccount: AccountId = Multisig::multi_account_id(&vec![ hex!["d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"].into(), // alice hex!["8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48"].into(), // bob @@ -1038,11 +1035,8 @@ parameter_types! { impl bifrost_salp::Config for Runtime { type BancorPool = Bancor; - type WeightToFee = IdentityFee; type BifrostXcmExecutor = BifrostXcmAdaptor>; - type DepositToken = NativeCurrencyId; type Event = Event; - type ExecuteXcmOrigin = EnsureXcmOrigin; type LeasePeriod = LeasePeriod; type MinContribution = MinContribution; type MultiCurrency = Currencies; @@ -1052,18 +1046,15 @@ impl bifrost_salp::Config for Runtime { type ReleaseRatio = ReleaseRatio; type RemoveKeysLimit = RemoveKeysLimit; type SlotLength = SlotLength; - type SubmissionDeposit = SubmissionDeposit; type VSBondValidPeriod = VSBondValidPeriod; type XcmTransferOrigin = XcmTransferOrigin; type WeightInfo = weights::bifrost_salp::WeightInfo; type SelfParaId = SelfParaId; type ContributionWeight = ContributionWeight; - type WithdrawWeight = WithdrawWeight; type BaseXcmWeight = XcmWeight; type EnsureConfirmAsMultiSig = EnsureOneOf; type AddProxyWeight = AddProxyWeight; - type RemoveProxyWeight = RemoveProxyWeight; type XcmTransfer = XTokens; type SovereignSubAccountLocation = RelaychainSovereignSubAccount; type TransactProxyType = SalpProxyType; diff --git a/runtime/bifrost/src/lib.rs b/runtime/bifrost/src/lib.rs index 32f54e863..76a5f794c 100644 --- a/runtime/bifrost/src/lib.rs +++ b/runtime/bifrost/src/lib.rs @@ -79,7 +79,7 @@ use frame_support::{ use frame_system::{EnsureOneOf, EnsureRoot, RawOrigin}; use hex_literal::hex; use node_primitives::{ - Amount, CurrencyId, Moment, Nonce, ParaId, ParachainDerivedProxyAccountType, + Amount, CurrencyId, Moment, Nonce, ParachainDerivedProxyAccountType, ParachainTransactProxyType, ParachainTransactType, TokenSymbol, TransferOriginType, XcmBaseWeight, }; @@ -99,7 +99,7 @@ use xcm_builder::{ EnsureXcmOrigin, FixedRateOfConcreteFungible, FixedWeightBounds, IsConcrete, LocationInverter, ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit, UsingComponents, + SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit, }; use xcm_executor::{Config, XcmExecutor}; use xcm_support::{BifrostCurrencyAdapter, BifrostXcmAdaptor, Get}; @@ -192,10 +192,11 @@ parameter_types! { parameter_types! { pub const TreasuryPalletId: PalletId = PalletId(*b"bf/trsry"); + pub const BifrostCrowdloanId: PalletId = PalletId(*b"bf/salp#"); } pub fn get_all_pallet_accounts() -> Vec { - vec![TreasuryPalletId::get().into_account()] + vec![TreasuryPalletId::get().into_account(), BifrostCrowdloanId::get().into_account()] } impl frame_system::Config for Runtime { @@ -211,7 +212,7 @@ impl frame_system::Config for Runtime { type BlockWeights = RuntimeBlockWeights; /// The aggregated dispatch type that is available for extrinsics. type Call = Call; - type DbWeight = (); + type DbWeight = RocksDbWeight; /// The ubiquitous event type. type Event = Event; /// The type for hashing blocks and tries. @@ -822,6 +823,7 @@ orml_traits::parameter_type_with_key! { &CurrencyId::Token(TokenSymbol::KSM) => 10 * MILLICENTS, &CurrencyId::VSToken(TokenSymbol::KSM) => 10 * MILLICENTS, &CurrencyId::VSBond(TokenSymbol::BNC, ..) => 10 * MILLICENTS, + &CurrencyId::VSBond(TokenSymbol::KSM, ..) => 10 * MILLICENTS, _ => Balance::max_value() // unsupported } }; @@ -921,9 +923,7 @@ impl EnsureOrigin for EnsureConfirmAsMultiSig { } parameter_types! { - pub const SubmissionDeposit: Balance = 100 * DOLLARS; pub const MinContribution: Balance = 1 * DOLLARS; - pub const BifrostCrowdloanId: PalletId = PalletId(*b"bf/salp#"); pub const RemoveKeysLimit: u32 = 500; pub const VSBondValidPeriod: BlockNumber = 30 * DAYS; pub const ReleaseCycle: BlockNumber = 1 * DAYS; @@ -933,9 +933,7 @@ parameter_types! { pub const XcmTransferOrigin: TransferOriginType = TransferOriginType::FromRelayChain; pub XcmWeight: XcmBaseWeight = XCM_WEIGHT.into(); pub ContributionWeight:XcmBaseWeight = XCM_WEIGHT.into(); - pub WithdrawWeight:XcmBaseWeight = XCM_WEIGHT.into(); pub AddProxyWeight:XcmBaseWeight = XCM_WEIGHT.into(); - pub RemoveProxyWeight:XcmBaseWeight = XCM_WEIGHT.into(); pub ConfirmMuitiSigAccount: AccountId = hex!["d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"].into(); pub RelaychainSovereignSubAccount: MultiLocation = create_x2_parachain_multilocation(ParachainDerivedProxyAccountType::Salp as u16); pub SalpTransactType: ParachainTransactType = ParachainTransactType::Xcm; @@ -944,11 +942,8 @@ parameter_types! { impl bifrost_salp::Config for Runtime { type BancorPool = Bancor; - type WeightToFee = IdentityFee; type BifrostXcmExecutor = BifrostXcmAdaptor>; - type DepositToken = NativeCurrencyId; type Event = Event; - type ExecuteXcmOrigin = EnsureXcmOrigin; type LeasePeriod = LeasePeriod; type MinContribution = MinContribution; type MultiCurrency = Currencies; @@ -958,18 +953,15 @@ impl bifrost_salp::Config for Runtime { type ReleaseRatio = ReleaseRatio; type RemoveKeysLimit = RemoveKeysLimit; type SlotLength = SlotLength; - type SubmissionDeposit = SubmissionDeposit; type VSBondValidPeriod = VSBondValidPeriod; type XcmTransferOrigin = XcmTransferOrigin; type WeightInfo = weights::bifrost_salp::WeightInfo; type SelfParaId = SelfParaId; type ContributionWeight = ContributionWeight; - type WithdrawWeight = WithdrawWeight; type BaseXcmWeight = XcmWeight; type EnsureConfirmAsMultiSig = EnsureOneOf; type AddProxyWeight = AddProxyWeight; - type RemoveProxyWeight = RemoveProxyWeight; type XcmTransfer = XTokens; type SovereignSubAccountLocation = RelaychainSovereignSubAccount; type TransactProxyType = SalpProxyType; diff --git a/runtime/dev/src/lib.rs b/runtime/dev/src/lib.rs index b73df56f5..bc8fceaa0 100644 --- a/runtime/dev/src/lib.rs +++ b/runtime/dev/src/lib.rs @@ -936,7 +936,6 @@ impl bifrost_minter_reward::Config for Runtime { use crate::constants::relay_fee::WeightToFee; parameter_types! { - pub const SubmissionDeposit: Balance = 100 * DOLLARS; pub const MinContribution: Balance = 1 * DOLLARS; pub const BifrostCrowdloanId: PalletId = PalletId(*b"bf/salp#"); pub const RemoveKeysLimit: u32 = 500; @@ -948,9 +947,7 @@ parameter_types! { pub const XcmTransferOrigin: TransferOriginType = TransferOriginType::FromRelayChain; pub XcmWeight: XcmBaseWeight = XCM_WEIGHT.into(); pub ContributionWeight:XcmBaseWeight = XCM_WEIGHT.into(); - pub WithdrawWeight:XcmBaseWeight = XCM_WEIGHT.into(); pub AddProxyWeight:XcmBaseWeight = XCM_WEIGHT.into(); - pub RemoveProxyWeight:XcmBaseWeight = XCM_WEIGHT.into(); pub ConfirmMuitiSigAccount: AccountId = hex![ "ce6072037670ca8e974fd571eae4f215a58d0bf823b998f619c3f87a911c3541" ] @@ -995,9 +992,7 @@ impl EnsureOrigin for EnsureConfirmAsMultiSig { impl bifrost_salp::Config for Runtime { type BancorPool = Bancor; type BifrostXcmExecutor = BifrostXcmAdaptor; - type DepositToken = NativeCurrencyId; type Event = Event; - type ExecuteXcmOrigin = EnsureXcmOrigin; type LeasePeriod = LeasePeriod; type MinContribution = MinContribution; type MultiCurrency = Currencies; @@ -1007,18 +1002,14 @@ impl bifrost_salp::Config for Runtime { type ReleaseRatio = ReleaseRatio; type RemoveKeysLimit = RemoveKeysLimit; type SlotLength = SlotLength; - type SubmissionDeposit = SubmissionDeposit; type VSBondValidPeriod = VSBondValidPeriod; type XcmTransferOrigin = XcmTransferOrigin; type WeightInfo = weights::bifrost_salp::WeightInfo; type SelfParaId = SelfParaId; type ContributionWeight = ContributionWeight; - type WithdrawWeight = WithdrawWeight; type BaseXcmWeight = XcmWeight; type EnsureConfirmAsMultiSig = EnsureConfirmAsMultiSig; - type WeightToFee = WeightToFee; type AddProxyWeight = AddProxyWeight; - type RemoveProxyWeight = RemoveProxyWeight; type XcmTransfer = XTokens; type SovereignSubAccountLocation = RelaychainSovereignSubAccount; type TransactProxyType = SalpTransactProxyType;