mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 07:31:02 +00:00
Removed pallet::getter usage from Polkadot Runtime pallets (#3660)
Part of #3326 @kianenigma @ggwpez polkadot address: 12poSUQPtcF1HUPQGY3zZu2P8emuW9YnsPduA4XG3oCEfJVp --------- Signed-off-by: Matteo Muraca <mmuraca247@gmail.com> Co-authored-by: ordian <write@reusable.software>
This commit is contained in:
@@ -39,8 +39,8 @@ pub mod v1 {
|
||||
const MAX_PERMANENT_SLOTS: u32 = 100;
|
||||
const MAX_TEMPORARY_SLOTS: u32 = 100;
|
||||
|
||||
<MaxPermanentSlots<T>>::put(MAX_PERMANENT_SLOTS);
|
||||
<MaxTemporarySlots<T>>::put(MAX_TEMPORARY_SLOTS);
|
||||
MaxPermanentSlots::<T>::put(MAX_PERMANENT_SLOTS);
|
||||
MaxTemporarySlots::<T>::put(MAX_TEMPORARY_SLOTS);
|
||||
// Return the weight consumed by the migration.
|
||||
T::DbWeight::get().reads_writes(1, 3)
|
||||
} else {
|
||||
@@ -53,8 +53,8 @@ pub mod v1 {
|
||||
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
|
||||
let on_chain_version = Pallet::<T>::on_chain_storage_version();
|
||||
ensure!(on_chain_version == 1, "assigned_slots::MigrateToV1 needs to be run");
|
||||
assert_eq!(<MaxPermanentSlots<T>>::get(), 100);
|
||||
assert_eq!(<MaxTemporarySlots<T>>::get(), 100);
|
||||
assert_eq!(MaxPermanentSlots::<T>::get(), 100);
|
||||
assert_eq!(MaxTemporarySlots::<T>::get(), 100);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,18 +148,15 @@ pub mod pallet {
|
||||
|
||||
/// Assigned permanent slots, with their start lease period, and duration.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn permanent_slots)]
|
||||
pub type PermanentSlots<T: Config> =
|
||||
StorageMap<_, Twox64Concat, ParaId, (LeasePeriodOf<T>, LeasePeriodOf<T>), OptionQuery>;
|
||||
|
||||
/// Number of assigned (and active) permanent slots.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn permanent_slot_count)]
|
||||
pub type PermanentSlotCount<T: Config> = StorageValue<_, u32, ValueQuery>;
|
||||
|
||||
/// Assigned temporary slots.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn temporary_slots)]
|
||||
pub type TemporarySlots<T: Config> = StorageMap<
|
||||
_,
|
||||
Twox64Concat,
|
||||
@@ -170,12 +167,10 @@ pub mod pallet {
|
||||
|
||||
/// Number of assigned temporary slots.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn temporary_slot_count)]
|
||||
pub type TemporarySlotCount<T: Config> = StorageValue<_, u32, ValueQuery>;
|
||||
|
||||
/// Number of active temporary slots in current slot lease period.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn active_temporary_slot_count)]
|
||||
pub type ActiveTemporarySlotCount<T: Config> = StorageValue<_, u32, ValueQuery>;
|
||||
|
||||
/// The max number of temporary slots that can be assigned.
|
||||
@@ -197,8 +192,8 @@ pub mod pallet {
|
||||
#[pallet::genesis_build]
|
||||
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
|
||||
fn build(&self) {
|
||||
<MaxPermanentSlots<T>>::put(&self.max_permanent_slots);
|
||||
<MaxTemporarySlots<T>>::put(&self.max_temporary_slots);
|
||||
MaxPermanentSlots::<T>::put(&self.max_permanent_slots);
|
||||
MaxTemporarySlots::<T>::put(&self.max_temporary_slots);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +301,7 @@ pub mod pallet {
|
||||
LeasePeriodOf::<T>::from(T::PermanentSlotLeasePeriodLength::get()),
|
||||
),
|
||||
);
|
||||
<PermanentSlotCount<T>>::mutate(|count| count.saturating_inc());
|
||||
PermanentSlotCount::<T>::mutate(|count| count.saturating_inc());
|
||||
|
||||
Self::deposit_event(Event::<T>::PermanentSlotAssigned(id));
|
||||
Ok(())
|
||||
@@ -364,7 +359,7 @@ pub mod pallet {
|
||||
};
|
||||
|
||||
if lease_period_start == SlotLeasePeriodStart::Current &&
|
||||
Self::active_temporary_slot_count() < T::MaxTemporarySlotPerLeasePeriod::get()
|
||||
ActiveTemporarySlotCount::<T>::get() < T::MaxTemporarySlotPerLeasePeriod::get()
|
||||
{
|
||||
// Try to allocate slot directly
|
||||
match Self::configure_slot_lease(
|
||||
@@ -394,7 +389,7 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
TemporarySlots::<T>::insert(id, temp_slot);
|
||||
<TemporarySlotCount<T>>::mutate(|count| count.saturating_inc());
|
||||
TemporarySlotCount::<T>::mutate(|count| count.saturating_inc());
|
||||
|
||||
Self::deposit_event(Event::<T>::TemporarySlotAssigned(id));
|
||||
|
||||
@@ -420,12 +415,12 @@ pub mod pallet {
|
||||
|
||||
if PermanentSlots::<T>::contains_key(id) {
|
||||
PermanentSlots::<T>::remove(id);
|
||||
<PermanentSlotCount<T>>::mutate(|count| *count = count.saturating_sub(One::one()));
|
||||
PermanentSlotCount::<T>::mutate(|count| *count = count.saturating_sub(One::one()));
|
||||
} else if TemporarySlots::<T>::contains_key(id) {
|
||||
TemporarySlots::<T>::remove(id);
|
||||
<TemporarySlotCount<T>>::mutate(|count| *count = count.saturating_sub(One::one()));
|
||||
TemporarySlotCount::<T>::mutate(|count| *count = count.saturating_sub(One::one()));
|
||||
if is_parachain {
|
||||
<ActiveTemporarySlotCount<T>>::mutate(|active_count| {
|
||||
ActiveTemporarySlotCount::<T>::mutate(|active_count| {
|
||||
*active_count = active_count.saturating_sub(One::one())
|
||||
});
|
||||
}
|
||||
@@ -456,7 +451,7 @@ pub mod pallet {
|
||||
pub fn set_max_permanent_slots(origin: OriginFor<T>, slots: u32) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
|
||||
<MaxPermanentSlots<T>>::put(slots);
|
||||
MaxPermanentSlots::<T>::put(slots);
|
||||
|
||||
Self::deposit_event(Event::<T>::MaxPermanentSlotsChanged { slots });
|
||||
Ok(())
|
||||
@@ -468,7 +463,7 @@ pub mod pallet {
|
||||
pub fn set_max_temporary_slots(origin: OriginFor<T>, slots: u32) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
|
||||
<MaxTemporarySlots<T>>::put(slots);
|
||||
MaxTemporarySlots::<T>::put(slots);
|
||||
|
||||
Self::deposit_event(Event::<T>::MaxTemporarySlotsChanged { slots });
|
||||
Ok(())
|
||||
@@ -965,7 +960,7 @@ mod tests {
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(2_u32),
|
||||
));
|
||||
assert_eq!(AssignedSlots::permanent_slot_count(), 2);
|
||||
assert_eq!(assigned_slots::PermanentSlotCount::<Test>::get(), 2);
|
||||
|
||||
assert_noop!(
|
||||
AssignedSlots::assign_perm_parachain_slot(
|
||||
@@ -989,8 +984,8 @@ mod tests {
|
||||
dummy_validation_code(),
|
||||
));
|
||||
|
||||
assert_eq!(AssignedSlots::permanent_slot_count(), 0);
|
||||
assert_eq!(AssignedSlots::permanent_slots(ParaId::from(1_u32)), None);
|
||||
assert_eq!(assigned_slots::PermanentSlotCount::<Test>::get(), 0);
|
||||
assert_eq!(assigned_slots::PermanentSlots::<Test>::get(ParaId::from(1_u32)), None);
|
||||
|
||||
assert_ok!(AssignedSlots::assign_perm_parachain_slot(
|
||||
RuntimeOrigin::root(),
|
||||
@@ -1004,9 +999,12 @@ mod tests {
|
||||
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(1_u32)), true);
|
||||
|
||||
assert_eq!(AssignedSlots::permanent_slot_count(), 1);
|
||||
assert_eq!(assigned_slots::PermanentSlotCount::<Test>::get(), 1);
|
||||
assert_eq!(AssignedSlots::has_permanent_slot(ParaId::from(1_u32)), true);
|
||||
assert_eq!(AssignedSlots::permanent_slots(ParaId::from(1_u32)), Some((0, 3)));
|
||||
assert_eq!(
|
||||
assigned_slots::PermanentSlots::<Test>::get(ParaId::from(1_u32)),
|
||||
Some((0, 3))
|
||||
);
|
||||
|
||||
assert_eq!(Slots::already_leased(ParaId::from(1_u32), 0, 2), true);
|
||||
|
||||
@@ -1138,7 +1136,7 @@ mod tests {
|
||||
));
|
||||
}
|
||||
|
||||
assert_eq!(AssignedSlots::temporary_slot_count(), 6);
|
||||
assert_eq!(assigned_slots::TemporarySlotCount::<Test>::get(), 6);
|
||||
|
||||
// Attempt to assign one more temp slot
|
||||
assert_ok!(TestRegistrar::<Test>::register(
|
||||
@@ -1170,15 +1168,15 @@ mod tests {
|
||||
dummy_validation_code(),
|
||||
));
|
||||
|
||||
assert_eq!(AssignedSlots::temporary_slots(ParaId::from(1_u32)), None);
|
||||
assert_eq!(assigned_slots::TemporarySlots::<Test>::get(ParaId::from(1_u32)), None);
|
||||
|
||||
assert_ok!(AssignedSlots::assign_temp_parachain_slot(
|
||||
RuntimeOrigin::root(),
|
||||
ParaId::from(1_u32),
|
||||
SlotLeasePeriodStart::Current
|
||||
));
|
||||
assert_eq!(AssignedSlots::temporary_slot_count(), 1);
|
||||
assert_eq!(AssignedSlots::active_temporary_slot_count(), 1);
|
||||
assert_eq!(assigned_slots::TemporarySlotCount::<Test>::get(), 1);
|
||||
assert_eq!(assigned_slots::ActiveTemporarySlotCount::<Test>::get(), 1);
|
||||
|
||||
// Block 1-5
|
||||
// Para is a lease holding parachain for TemporarySlotLeasePeriodLength * LeasePeriod
|
||||
@@ -1186,14 +1184,14 @@ mod tests {
|
||||
while block < 6 {
|
||||
println!("block #{}", block);
|
||||
println!("lease period #{}", AssignedSlots::current_lease_period_index());
|
||||
println!("lease {:?}", Slots::lease(ParaId::from(1_u32)));
|
||||
println!("lease {:?}", slots::Leases::<Test>::get(ParaId::from(1_u32)));
|
||||
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(1_u32)), true);
|
||||
|
||||
assert_eq!(AssignedSlots::has_temporary_slot(ParaId::from(1_u32)), true);
|
||||
assert_eq!(AssignedSlots::active_temporary_slot_count(), 1);
|
||||
assert_eq!(assigned_slots::ActiveTemporarySlotCount::<Test>::get(), 1);
|
||||
assert_eq!(
|
||||
AssignedSlots::temporary_slots(ParaId::from(1_u32)),
|
||||
assigned_slots::TemporarySlots::<Test>::get(ParaId::from(1_u32)),
|
||||
Some(ParachainTemporarySlot {
|
||||
manager: 1,
|
||||
period_begin: 0,
|
||||
@@ -1212,23 +1210,23 @@ mod tests {
|
||||
// Block 6
|
||||
println!("block #{}", block);
|
||||
println!("lease period #{}", AssignedSlots::current_lease_period_index());
|
||||
println!("lease {:?}", Slots::lease(ParaId::from(1_u32)));
|
||||
println!("lease {:?}", slots::Leases::<Test>::get(ParaId::from(1_u32)));
|
||||
|
||||
// Para lease ended, downgraded back to on-demand parachain
|
||||
assert_eq!(TestRegistrar::<Test>::is_parathread(ParaId::from(1_u32)), true);
|
||||
assert_eq!(Slots::already_leased(ParaId::from(1_u32), 0, 3), false);
|
||||
assert_eq!(AssignedSlots::active_temporary_slot_count(), 0);
|
||||
assert_eq!(assigned_slots::ActiveTemporarySlotCount::<Test>::get(), 0);
|
||||
|
||||
// Block 12
|
||||
// Para should get a turn after TemporarySlotLeasePeriodLength * LeasePeriod blocks
|
||||
run_to_block(12);
|
||||
println!("block #{}", block);
|
||||
println!("lease period #{}", AssignedSlots::current_lease_period_index());
|
||||
println!("lease {:?}", Slots::lease(ParaId::from(1_u32)));
|
||||
println!("lease {:?}", slots::Leases::<Test>::get(ParaId::from(1_u32)));
|
||||
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(1_u32)), true);
|
||||
assert_eq!(Slots::already_leased(ParaId::from(1_u32), 4, 5), true);
|
||||
assert_eq!(AssignedSlots::active_temporary_slot_count(), 1);
|
||||
assert_eq!(assigned_slots::ActiveTemporarySlotCount::<Test>::get(), 1);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1270,7 +1268,7 @@ mod tests {
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(3_u32)), false);
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(4_u32)), false);
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(5_u32)), false);
|
||||
assert_eq!(AssignedSlots::active_temporary_slot_count(), 2);
|
||||
assert_eq!(assigned_slots::ActiveTemporarySlotCount::<Test>::get(), 2);
|
||||
}
|
||||
|
||||
// Block 6-11, Period 2-3
|
||||
@@ -1282,7 +1280,7 @@ mod tests {
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(3_u32)), true);
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(4_u32)), false);
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(5_u32)), false);
|
||||
assert_eq!(AssignedSlots::active_temporary_slot_count(), 2);
|
||||
assert_eq!(assigned_slots::ActiveTemporarySlotCount::<Test>::get(), 2);
|
||||
}
|
||||
|
||||
// Block 12-17, Period 4-5
|
||||
@@ -1294,7 +1292,7 @@ mod tests {
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(3_u32)), false);
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(4_u32)), true);
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(5_u32)), true);
|
||||
assert_eq!(AssignedSlots::active_temporary_slot_count(), 2);
|
||||
assert_eq!(assigned_slots::ActiveTemporarySlotCount::<Test>::get(), 2);
|
||||
}
|
||||
|
||||
// Block 18-23, Period 6-7
|
||||
@@ -1306,7 +1304,7 @@ mod tests {
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(3_u32)), false);
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(4_u32)), false);
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(5_u32)), false);
|
||||
assert_eq!(AssignedSlots::active_temporary_slot_count(), 2);
|
||||
assert_eq!(assigned_slots::ActiveTemporarySlotCount::<Test>::get(), 2);
|
||||
}
|
||||
|
||||
// Block 24-29, Period 8-9
|
||||
@@ -1318,7 +1316,7 @@ mod tests {
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(3_u32)), true);
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(4_u32)), false);
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(5_u32)), false);
|
||||
assert_eq!(AssignedSlots::active_temporary_slot_count(), 2);
|
||||
assert_eq!(assigned_slots::ActiveTemporarySlotCount::<Test>::get(), 2);
|
||||
}
|
||||
|
||||
// Block 30-35, Period 10-11
|
||||
@@ -1330,7 +1328,7 @@ mod tests {
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(3_u32)), false);
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(4_u32)), true);
|
||||
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(5_u32)), true);
|
||||
assert_eq!(AssignedSlots::active_temporary_slot_count(), 2);
|
||||
assert_eq!(assigned_slots::ActiveTemporarySlotCount::<Test>::get(), 2);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1386,9 +1384,9 @@ mod tests {
|
||||
ParaId::from(1_u32),
|
||||
));
|
||||
|
||||
assert_eq!(AssignedSlots::permanent_slot_count(), 0);
|
||||
assert_eq!(assigned_slots::PermanentSlotCount::<Test>::get(), 0);
|
||||
assert_eq!(AssignedSlots::has_permanent_slot(ParaId::from(1_u32)), false);
|
||||
assert_eq!(AssignedSlots::permanent_slots(ParaId::from(1_u32)), None);
|
||||
assert_eq!(assigned_slots::PermanentSlots::<Test>::get(ParaId::from(1_u32)), None);
|
||||
|
||||
assert_eq!(Slots::already_leased(ParaId::from(1_u32), 0, 2), false);
|
||||
});
|
||||
@@ -1419,10 +1417,10 @@ mod tests {
|
||||
ParaId::from(1_u32),
|
||||
));
|
||||
|
||||
assert_eq!(AssignedSlots::temporary_slot_count(), 0);
|
||||
assert_eq!(AssignedSlots::active_temporary_slot_count(), 0);
|
||||
assert_eq!(assigned_slots::TemporarySlotCount::<Test>::get(), 0);
|
||||
assert_eq!(assigned_slots::ActiveTemporarySlotCount::<Test>::get(), 0);
|
||||
assert_eq!(AssignedSlots::has_temporary_slot(ParaId::from(1_u32)), false);
|
||||
assert_eq!(AssignedSlots::temporary_slots(ParaId::from(1_u32)), None);
|
||||
assert_eq!(assigned_slots::TemporarySlots::<Test>::get(ParaId::from(1_u32)), None);
|
||||
|
||||
assert_eq!(Slots::already_leased(ParaId::from(1_u32), 0, 1), false);
|
||||
});
|
||||
|
||||
@@ -174,7 +174,6 @@ pub mod pallet {
|
||||
|
||||
/// Number of auctions started so far.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn auction_counter)]
|
||||
pub type AuctionCounter<T> = StorageValue<_, AuctionIndex, ValueQuery>;
|
||||
|
||||
/// Information relating to the current auction, if there is one.
|
||||
@@ -183,13 +182,11 @@ pub mod pallet {
|
||||
/// contiguous lease periods on auction is for. The second is the block number when the
|
||||
/// auction will "begin to end", i.e. the first block of the Ending Period of the auction.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn auction_info)]
|
||||
pub type AuctionInfo<T: Config> = StorageValue<_, (LeasePeriodOf<T>, BlockNumberFor<T>)>;
|
||||
|
||||
/// Amounts currently reserved in the accounts of the bidders currently winning
|
||||
/// (sub-)ranges.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn reserved_amounts)]
|
||||
pub type ReservedAmounts<T: Config> =
|
||||
StorageMap<_, Twox64Concat, (T::AccountId, ParaId), BalanceOf<T>>;
|
||||
|
||||
@@ -197,7 +194,6 @@ pub mod pallet {
|
||||
/// the current auction. The map's key is the 0-based index into the Sample Size. The
|
||||
/// first sample of the ending period is 0; the last is `Sample Size - 1`.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn winning)]
|
||||
pub type Winning<T: Config> = StorageMap<_, Twox64Concat, BlockNumberFor<T>, WinningData<T>>;
|
||||
|
||||
#[pallet::extra_constants]
|
||||
@@ -983,7 +979,7 @@ mod tests {
|
||||
assert_eq!(Balances::reserved_balance(1), 5);
|
||||
assert_eq!(Balances::free_balance(1), 5);
|
||||
assert_eq!(
|
||||
Auctions::winning(0).unwrap()[SlotRange::ZeroThree as u8 as usize],
|
||||
Winning::<Test>::get(0).unwrap()[SlotRange::ZeroThree as u8 as usize],
|
||||
Some((1, 0.into(), 5))
|
||||
);
|
||||
});
|
||||
@@ -1016,7 +1012,7 @@ mod tests {
|
||||
assert_eq!(Balances::reserved_balance(2), 6);
|
||||
assert_eq!(Balances::free_balance(2), 14);
|
||||
assert_eq!(
|
||||
Auctions::winning(0).unwrap()[SlotRange::ZeroThree as u8 as usize],
|
||||
Winning::<Test>::get(0).unwrap()[SlotRange::ZeroThree as u8 as usize],
|
||||
Some((2, 0.into(), 6))
|
||||
);
|
||||
});
|
||||
@@ -1453,7 +1449,7 @@ mod tests {
|
||||
let mut winning = [None; SlotRange::SLOT_RANGE_COUNT];
|
||||
winning[SlotRange::ZeroThree as u8 as usize] = Some((1, para_1, 9));
|
||||
winning[SlotRange::TwoThree as u8 as usize] = Some((2, para_2, 19));
|
||||
assert_eq!(Auctions::winning(0), Some(winning));
|
||||
assert_eq!(Winning::<Test>::get(0), Some(winning));
|
||||
|
||||
run_to_block(9);
|
||||
assert_eq!(
|
||||
@@ -1466,14 +1462,14 @@ mod tests {
|
||||
Auctions::auction_status(System::block_number()),
|
||||
AuctionStatus::<u32>::EndingPeriod(0, 0)
|
||||
);
|
||||
assert_eq!(Auctions::winning(0), Some(winning));
|
||||
assert_eq!(Winning::<Test>::get(0), Some(winning));
|
||||
|
||||
run_to_block(11);
|
||||
assert_eq!(
|
||||
Auctions::auction_status(System::block_number()),
|
||||
AuctionStatus::<u32>::EndingPeriod(1, 0)
|
||||
);
|
||||
assert_eq!(Auctions::winning(1), Some(winning));
|
||||
assert_eq!(Winning::<Test>::get(1), Some(winning));
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 3, 4, 29));
|
||||
|
||||
run_to_block(12);
|
||||
@@ -1482,7 +1478,7 @@ mod tests {
|
||||
AuctionStatus::<u32>::EndingPeriod(2, 0)
|
||||
);
|
||||
winning[SlotRange::TwoThree as u8 as usize] = Some((3, para_3, 29));
|
||||
assert_eq!(Auctions::winning(2), Some(winning));
|
||||
assert_eq!(Winning::<Test>::get(2), Some(winning));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1569,7 +1565,7 @@ mod tests {
|
||||
let mut winning = [None; SlotRange::SLOT_RANGE_COUNT];
|
||||
winning[SlotRange::ZeroThree as u8 as usize] = Some((1, para_1, 9));
|
||||
winning[SlotRange::TwoThree as u8 as usize] = Some((2, para_2, 19));
|
||||
assert_eq!(Auctions::winning(0), Some(winning));
|
||||
assert_eq!(Winning::<Test>::get(0), Some(winning));
|
||||
|
||||
run_to_block(9);
|
||||
assert_eq!(
|
||||
@@ -1582,31 +1578,31 @@ mod tests {
|
||||
Auctions::auction_status(System::block_number()),
|
||||
AuctionStatus::<u32>::EndingPeriod(0, 0)
|
||||
);
|
||||
assert_eq!(Auctions::winning(0), Some(winning));
|
||||
assert_eq!(Winning::<Test>::get(0), Some(winning));
|
||||
|
||||
// New bids update the current winning
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 14, 14, 29));
|
||||
winning[SlotRange::ThreeThree as u8 as usize] = Some((3, para_3, 29));
|
||||
assert_eq!(Auctions::winning(0), Some(winning));
|
||||
assert_eq!(Winning::<Test>::get(0), Some(winning));
|
||||
|
||||
run_to_block(20);
|
||||
assert_eq!(
|
||||
Auctions::auction_status(System::block_number()),
|
||||
AuctionStatus::<u32>::EndingPeriod(1, 0)
|
||||
);
|
||||
assert_eq!(Auctions::winning(1), Some(winning));
|
||||
assert_eq!(Winning::<Test>::get(1), Some(winning));
|
||||
run_to_block(25);
|
||||
// Overbid mid sample
|
||||
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 13, 14, 29));
|
||||
winning[SlotRange::TwoThree as u8 as usize] = Some((3, para_3, 29));
|
||||
assert_eq!(Auctions::winning(1), Some(winning));
|
||||
assert_eq!(Winning::<Test>::get(1), Some(winning));
|
||||
|
||||
run_to_block(30);
|
||||
assert_eq!(
|
||||
Auctions::auction_status(System::block_number()),
|
||||
AuctionStatus::<u32>::EndingPeriod(2, 0)
|
||||
);
|
||||
assert_eq!(Auctions::winning(2), Some(winning));
|
||||
assert_eq!(Winning::<Test>::get(2), Some(winning));
|
||||
|
||||
set_last_random(H256::from([254; 32]), 40);
|
||||
run_to_block(40);
|
||||
|
||||
@@ -203,20 +203,17 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn claims)]
|
||||
pub(super) type Claims<T: Config> = StorageMap<_, Identity, EthereumAddress, BalanceOf<T>>;
|
||||
pub type Claims<T: Config> = StorageMap<_, Identity, EthereumAddress, BalanceOf<T>>;
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn total)]
|
||||
pub(super) type Total<T: Config> = StorageValue<_, BalanceOf<T>, ValueQuery>;
|
||||
pub type Total<T: Config> = StorageValue<_, BalanceOf<T>, ValueQuery>;
|
||||
|
||||
/// Vesting schedule for a claim.
|
||||
/// First balance is the total amount that should be held for vesting.
|
||||
/// Second balance is how much should be unlocked per block.
|
||||
/// The block number is when the vesting should start.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn vesting)]
|
||||
pub(super) type Vesting<T: Config> =
|
||||
pub type Vesting<T: Config> =
|
||||
StorageMap<_, Identity, EthereumAddress, (BalanceOf<T>, BalanceOf<T>, BlockNumberFor<T>)>;
|
||||
|
||||
/// The statement kind that must be signed, if any.
|
||||
@@ -341,10 +338,10 @@ pub mod pallet {
|
||||
) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
|
||||
<Total<T>>::mutate(|t| *t += value);
|
||||
<Claims<T>>::insert(who, value);
|
||||
Total::<T>::mutate(|t| *t += value);
|
||||
Claims::<T>::insert(who, value);
|
||||
if let Some(vs) = vesting_schedule {
|
||||
<Vesting<T>>::insert(who, vs);
|
||||
Vesting::<T>::insert(who, vs);
|
||||
}
|
||||
if let Some(s) = statement {
|
||||
Signing::<T>::insert(who, s);
|
||||
@@ -492,7 +489,7 @@ pub mod pallet {
|
||||
))?;
|
||||
|
||||
let e = InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into());
|
||||
ensure!(<Claims<T>>::contains_key(&signer), e);
|
||||
ensure!(Claims::<T>::contains_key(&signer), e);
|
||||
|
||||
let e = InvalidTransaction::Custom(ValidityError::InvalidStatement.into());
|
||||
match Signing::<T>::get(signer) {
|
||||
@@ -551,9 +548,10 @@ impl<T: Config> Pallet<T> {
|
||||
}
|
||||
|
||||
fn process_claim(signer: EthereumAddress, dest: T::AccountId) -> sp_runtime::DispatchResult {
|
||||
let balance_due = <Claims<T>>::get(&signer).ok_or(Error::<T>::SignerHasNoClaim)?;
|
||||
let balance_due = Claims::<T>::get(&signer).ok_or(Error::<T>::SignerHasNoClaim)?;
|
||||
|
||||
let new_total = Self::total().checked_sub(&balance_due).ok_or(Error::<T>::PotUnderflow)?;
|
||||
let new_total =
|
||||
Total::<T>::get().checked_sub(&balance_due).ok_or(Error::<T>::PotUnderflow)?;
|
||||
|
||||
let vesting = Vesting::<T>::get(&signer);
|
||||
if vesting.is_some() && T::VestingSchedule::vesting_balance(&dest).is_some() {
|
||||
@@ -571,9 +569,9 @@ impl<T: Config> Pallet<T> {
|
||||
.expect("No other vesting schedule exists, as checked above; qed");
|
||||
}
|
||||
|
||||
<Total<T>>::put(new_total);
|
||||
<Claims<T>>::remove(&signer);
|
||||
<Vesting<T>>::remove(&signer);
|
||||
Total::<T>::put(new_total);
|
||||
Claims::<T>::remove(&signer);
|
||||
Vesting::<T>::remove(&signer);
|
||||
Signing::<T>::remove(&signer);
|
||||
|
||||
// Let's deposit an event to let the outside world know this happened.
|
||||
@@ -683,7 +681,7 @@ mod secp_utils {
|
||||
what: &[u8],
|
||||
extra: &[u8],
|
||||
) -> EcdsaSignature {
|
||||
let msg = keccak_256(&<super::Pallet<T>>::ethereum_signable_message(
|
||||
let msg = keccak_256(&super::Pallet::<T>::ethereum_signable_message(
|
||||
&to_ascii_hex(what)[..],
|
||||
extra,
|
||||
));
|
||||
@@ -837,13 +835,13 @@ mod tests {
|
||||
#[test]
|
||||
fn basic_setup_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_eq!(Claims::total(), total_claims());
|
||||
assert_eq!(Claims::claims(ð(&alice())), Some(100));
|
||||
assert_eq!(Claims::claims(ð(&dave())), Some(200));
|
||||
assert_eq!(Claims::claims(ð(&eve())), Some(300));
|
||||
assert_eq!(Claims::claims(ð(&frank())), Some(400));
|
||||
assert_eq!(Claims::claims(&EthereumAddress::default()), None);
|
||||
assert_eq!(Claims::vesting(ð(&alice())), Some((50, 10, 1)));
|
||||
assert_eq!(claims::Total::<Test>::get(), total_claims());
|
||||
assert_eq!(claims::Claims::<Test>::get(ð(&alice())), Some(100));
|
||||
assert_eq!(claims::Claims::<Test>::get(ð(&dave())), Some(200));
|
||||
assert_eq!(claims::Claims::<Test>::get(ð(&eve())), Some(300));
|
||||
assert_eq!(claims::Claims::<Test>::get(ð(&frank())), Some(400));
|
||||
assert_eq!(claims::Claims::<Test>::get(&EthereumAddress::default()), None);
|
||||
assert_eq!(claims::Vesting::<Test>::get(ð(&alice())), Some((50, 10, 1)));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -867,7 +865,7 @@ mod tests {
|
||||
));
|
||||
assert_eq!(Balances::free_balance(&42), 100);
|
||||
assert_eq!(Vesting::vesting_balance(&42), Some(50));
|
||||
assert_eq!(Claims::total(), total_claims() - 100);
|
||||
assert_eq!(claims::Total::<Test>::get(), total_claims() - 100);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -900,7 +898,7 @@ mod tests {
|
||||
));
|
||||
assert_eq!(Balances::free_balance(&42), 100);
|
||||
assert_eq!(Vesting::vesting_balance(&42), Some(50));
|
||||
assert_eq!(Claims::total(), total_claims() - 100);
|
||||
assert_eq!(claims::Total::<Test>::get(), total_claims() - 100);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1004,7 +1002,7 @@ mod tests {
|
||||
StatementKind::Regular.to_text().to_vec()
|
||||
));
|
||||
assert_eq!(Balances::free_balance(&42), 200);
|
||||
assert_eq!(Claims::total(), total_claims() - 200);
|
||||
assert_eq!(claims::Total::<Test>::get(), total_claims() - 200);
|
||||
|
||||
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text());
|
||||
let r = Claims::claim_attest(
|
||||
@@ -1037,7 +1035,7 @@ mod tests {
|
||||
StatementKind::Saft.to_text().to_vec()
|
||||
));
|
||||
assert_eq!(Balances::free_balance(&42), 300);
|
||||
assert_eq!(Claims::total(), total_claims() - 300);
|
||||
assert_eq!(claims::Total::<Test>::get(), total_claims() - 300);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1058,7 +1056,7 @@ mod tests {
|
||||
StatementKind::Saft.to_text().to_vec()
|
||||
));
|
||||
assert_eq!(Balances::free_balance(&42), 100 + 300);
|
||||
assert_eq!(Claims::total(), total_claims() - 400);
|
||||
assert_eq!(claims::Total::<Test>::get(), total_claims() - 400);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1122,7 +1120,7 @@ mod tests {
|
||||
Error::<Test>::SignerHasNoClaim,
|
||||
);
|
||||
assert_ok!(Claims::mint_claim(RuntimeOrigin::root(), eth(&bob()), 200, None, None));
|
||||
assert_eq!(Claims::total(), total_claims() + 200);
|
||||
assert_eq!(claims::Total::<Test>::get(), total_claims() + 200);
|
||||
assert_ok!(Claims::claim(
|
||||
RuntimeOrigin::none(),
|
||||
69,
|
||||
@@ -1130,7 +1128,7 @@ mod tests {
|
||||
));
|
||||
assert_eq!(Balances::free_balance(&69), 200);
|
||||
assert_eq!(Vesting::vesting_balance(&69), None);
|
||||
assert_eq!(Claims::total(), total_claims());
|
||||
assert_eq!(claims::Total::<Test>::get(), total_claims());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1284,7 +1282,7 @@ mod tests {
|
||||
None
|
||||
));
|
||||
// New total
|
||||
assert_eq!(Claims::total(), total_claims() + 200);
|
||||
assert_eq!(claims::Total::<Test>::get(), total_claims() + 200);
|
||||
|
||||
// They should not be able to claim
|
||||
assert_noop!(
|
||||
@@ -1347,7 +1345,7 @@ mod tests {
|
||||
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_eq!(
|
||||
<Pallet<Test>>::validate_unsigned(
|
||||
Pallet::<Test>::validate_unsigned(
|
||||
source,
|
||||
&ClaimsCall::claim {
|
||||
dest: 1,
|
||||
@@ -1363,14 +1361,14 @@ mod tests {
|
||||
})
|
||||
);
|
||||
assert_eq!(
|
||||
<Pallet<Test>>::validate_unsigned(
|
||||
Pallet::<Test>::validate_unsigned(
|
||||
source,
|
||||
&ClaimsCall::claim { dest: 0, ethereum_signature: EcdsaSignature([0; 65]) }
|
||||
),
|
||||
InvalidTransaction::Custom(ValidityError::InvalidEthereumSignature.into()).into(),
|
||||
);
|
||||
assert_eq!(
|
||||
<Pallet<Test>>::validate_unsigned(
|
||||
Pallet::<Test>::validate_unsigned(
|
||||
source,
|
||||
&ClaimsCall::claim {
|
||||
dest: 1,
|
||||
@@ -1386,7 +1384,7 @@ mod tests {
|
||||
statement: StatementKind::Regular.to_text().to_vec(),
|
||||
};
|
||||
assert_eq!(
|
||||
<Pallet<Test>>::validate_unsigned(source, &call),
|
||||
Pallet::<Test>::validate_unsigned(source, &call),
|
||||
Ok(ValidTransaction {
|
||||
priority: 100,
|
||||
requires: vec![],
|
||||
@@ -1396,7 +1394,7 @@ mod tests {
|
||||
})
|
||||
);
|
||||
assert_eq!(
|
||||
<Pallet<Test>>::validate_unsigned(
|
||||
Pallet::<Test>::validate_unsigned(
|
||||
source,
|
||||
&ClaimsCall::claim_attest {
|
||||
dest: 1,
|
||||
@@ -1414,7 +1412,7 @@ mod tests {
|
||||
statement: StatementKind::Regular.to_text().to_vec(),
|
||||
};
|
||||
assert_eq!(
|
||||
<Pallet<Test>>::validate_unsigned(source, &call),
|
||||
Pallet::<Test>::validate_unsigned(source, &call),
|
||||
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
|
||||
);
|
||||
|
||||
@@ -1425,7 +1423,7 @@ mod tests {
|
||||
statement: StatementKind::Regular.to_text().to_vec(),
|
||||
};
|
||||
assert_eq!(
|
||||
<Pallet<Test>>::validate_unsigned(source, &call),
|
||||
Pallet::<Test>::validate_unsigned(source, &call),
|
||||
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
|
||||
);
|
||||
|
||||
@@ -1436,7 +1434,7 @@ mod tests {
|
||||
statement: StatementKind::Saft.to_text().to_vec(),
|
||||
};
|
||||
assert_eq!(
|
||||
<Pallet<Test>>::validate_unsigned(source, &call),
|
||||
Pallet::<Test>::validate_unsigned(source, &call),
|
||||
InvalidTransaction::Custom(ValidityError::InvalidStatement.into()).into(),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -225,8 +225,7 @@ pub mod pallet {
|
||||
|
||||
/// Info on all of the funds.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn funds)]
|
||||
pub(crate) type Funds<T: Config> = StorageMap<
|
||||
pub type Funds<T: Config> = StorageMap<
|
||||
_,
|
||||
Twox64Concat,
|
||||
ParaId,
|
||||
@@ -236,18 +235,15 @@ pub mod pallet {
|
||||
/// The funds that have had additional contributions during the last block. This is used
|
||||
/// in order to determine which funds should submit new or updated bids.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn new_raise)]
|
||||
pub(super) type NewRaise<T> = StorageValue<_, Vec<ParaId>, ValueQuery>;
|
||||
pub type NewRaise<T> = StorageValue<_, Vec<ParaId>, ValueQuery>;
|
||||
|
||||
/// The number of auctions that have entered into their ending period so far.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn endings_count)]
|
||||
pub(super) type EndingsCount<T> = StorageValue<_, u32, ValueQuery>;
|
||||
pub type EndingsCount<T> = StorageValue<_, u32, ValueQuery>;
|
||||
|
||||
/// Tracker for the next available fund index
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn next_fund_index)]
|
||||
pub(super) type NextFundIndex<T> = StorageValue<_, u32, ValueQuery>;
|
||||
pub type NextFundIndex<T> = StorageValue<_, u32, ValueQuery>;
|
||||
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
@@ -338,7 +334,7 @@ pub mod pallet {
|
||||
let new_raise = NewRaise::<T>::take();
|
||||
let new_raise_len = new_raise.len() as u32;
|
||||
for (fund, para_id) in
|
||||
new_raise.into_iter().filter_map(|i| Self::funds(i).map(|f| (f, i)))
|
||||
new_raise.into_iter().filter_map(|i| Funds::<T>::get(i).map(|f| (f, i)))
|
||||
{
|
||||
// Care needs to be taken by the crowdloan creator that this function will
|
||||
// succeed given the crowdloaning configuration. We do some checks ahead of time
|
||||
@@ -412,7 +408,7 @@ pub mod pallet {
|
||||
ensure!(depositor == manager, Error::<T>::InvalidOrigin);
|
||||
ensure!(T::Registrar::is_registered(index), Error::<T>::InvalidParaId);
|
||||
|
||||
let fund_index = Self::next_fund_index();
|
||||
let fund_index = NextFundIndex::<T>::get();
|
||||
let new_fund_index = fund_index.checked_add(1).ok_or(Error::<T>::Overflow)?;
|
||||
|
||||
let deposit = T::SubmissionDeposit::get();
|
||||
@@ -482,7 +478,7 @@ pub mod pallet {
|
||||
) -> DispatchResult {
|
||||
ensure_signed(origin)?;
|
||||
|
||||
let mut fund = Self::funds(index).ok_or(Error::<T>::InvalidParaId)?;
|
||||
let mut fund = Funds::<T>::get(index).ok_or(Error::<T>::InvalidParaId)?;
|
||||
let now = frame_system::Pallet::<T>::block_number();
|
||||
let fund_account = Self::fund_account_id(fund.fund_index);
|
||||
Self::ensure_crowdloan_ended(now, &fund_account, &fund)?;
|
||||
@@ -515,7 +511,7 @@ pub mod pallet {
|
||||
) -> DispatchResultWithPostInfo {
|
||||
ensure_signed(origin)?;
|
||||
|
||||
let mut fund = Self::funds(index).ok_or(Error::<T>::InvalidParaId)?;
|
||||
let mut fund = Funds::<T>::get(index).ok_or(Error::<T>::InvalidParaId)?;
|
||||
let now = frame_system::Pallet::<T>::block_number();
|
||||
let fund_account = Self::fund_account_id(fund.fund_index);
|
||||
Self::ensure_crowdloan_ended(now, &fund_account, &fund)?;
|
||||
@@ -558,7 +554,7 @@ pub mod pallet {
|
||||
pub fn dissolve(origin: OriginFor<T>, #[pallet::compact] index: ParaId) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
let fund = Self::funds(index).ok_or(Error::<T>::InvalidParaId)?;
|
||||
let fund = Funds::<T>::get(index).ok_or(Error::<T>::InvalidParaId)?;
|
||||
let pot = Self::fund_account_id(fund.fund_index);
|
||||
let now = frame_system::Pallet::<T>::block_number();
|
||||
|
||||
@@ -599,7 +595,7 @@ pub mod pallet {
|
||||
) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
|
||||
let fund = Self::funds(index).ok_or(Error::<T>::InvalidParaId)?;
|
||||
let fund = Funds::<T>::get(index).ok_or(Error::<T>::InvalidParaId)?;
|
||||
|
||||
Funds::<T>::insert(
|
||||
index,
|
||||
@@ -630,7 +626,7 @@ pub mod pallet {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
ensure!(memo.len() <= T::MaxMemoLength::get().into(), Error::<T>::MemoTooLarge);
|
||||
let fund = Self::funds(index).ok_or(Error::<T>::InvalidParaId)?;
|
||||
let fund = Funds::<T>::get(index).ok_or(Error::<T>::InvalidParaId)?;
|
||||
|
||||
let (balance, _) = Self::contribution_get(fund.fund_index, &who);
|
||||
ensure!(balance > Zero::zero(), Error::<T>::NoContributions);
|
||||
@@ -647,7 +643,7 @@ pub mod pallet {
|
||||
#[pallet::weight(T::WeightInfo::poke())]
|
||||
pub fn poke(origin: OriginFor<T>, index: ParaId) -> DispatchResult {
|
||||
ensure_signed(origin)?;
|
||||
let fund = Self::funds(index).ok_or(Error::<T>::InvalidParaId)?;
|
||||
let fund = Funds::<T>::get(index).ok_or(Error::<T>::InvalidParaId)?;
|
||||
ensure!(!fund.raised.is_zero(), Error::<T>::NoContributions);
|
||||
ensure!(!NewRaise::<T>::get().contains(&index), Error::<T>::AlreadyInNewRaise);
|
||||
NewRaise::<T>::append(index);
|
||||
@@ -757,12 +753,12 @@ impl<T: Config> Pallet<T> {
|
||||
existence: ExistenceRequirement,
|
||||
) -> DispatchResult {
|
||||
ensure!(value >= T::MinContribution::get(), Error::<T>::ContributionTooSmall);
|
||||
let mut fund = Self::funds(index).ok_or(Error::<T>::InvalidParaId)?;
|
||||
let mut fund = Funds::<T>::get(index).ok_or(Error::<T>::InvalidParaId)?;
|
||||
fund.raised = fund.raised.checked_add(&value).ok_or(Error::<T>::Overflow)?;
|
||||
ensure!(fund.raised <= fund.cap, Error::<T>::CapExceeded);
|
||||
|
||||
// Make sure crowdloan has not ended
|
||||
let now = <frame_system::Pallet<T>>::block_number();
|
||||
let now = frame_system::Pallet::<T>::block_number();
|
||||
ensure!(now < fund.end, Error::<T>::ContributionPeriodOver);
|
||||
|
||||
// Make sure crowdloan is in a valid lease period
|
||||
@@ -811,7 +807,7 @@ impl<T: Config> Pallet<T> {
|
||||
},
|
||||
}
|
||||
} else {
|
||||
let endings_count = Self::endings_count();
|
||||
let endings_count = EndingsCount::<T>::get();
|
||||
match fund.last_contribution {
|
||||
LastContribution::PreEnding(a) if a == endings_count => {
|
||||
// Not in ending period and no auctions have ended ending since our
|
||||
@@ -1155,11 +1151,11 @@ mod tests {
|
||||
fn basic_setup_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_eq!(System::block_number(), 0);
|
||||
assert_eq!(Crowdloan::funds(ParaId::from(0)), None);
|
||||
assert_eq!(crowdloan::Funds::<Test>::get(ParaId::from(0)), None);
|
||||
let empty: Vec<ParaId> = Vec::new();
|
||||
assert_eq!(Crowdloan::new_raise(), empty);
|
||||
assert_eq!(crowdloan::NewRaise::<Test>::get(), empty);
|
||||
assert_eq!(Crowdloan::contribution_get(0u32, &1).0, 0);
|
||||
assert_eq!(Crowdloan::endings_count(), 0);
|
||||
assert_eq!(crowdloan::EndingsCount::<Test>::get(), 0);
|
||||
|
||||
assert_ok!(TestAuctioneer::new_auction(5, 0));
|
||||
|
||||
@@ -1201,14 +1197,14 @@ mod tests {
|
||||
last_period: 4,
|
||||
fund_index: 0,
|
||||
};
|
||||
assert_eq!(Crowdloan::funds(para), Some(fund_info));
|
||||
assert_eq!(crowdloan::Funds::<Test>::get(para), Some(fund_info));
|
||||
// User has deposit removed from their free balance
|
||||
assert_eq!(Balances::free_balance(1), 999);
|
||||
// Deposit is placed in reserved
|
||||
assert_eq!(Balances::reserved_balance(1), 1);
|
||||
// No new raise until first contribution
|
||||
let empty: Vec<ParaId> = Vec::new();
|
||||
assert_eq!(Crowdloan::new_raise(), empty);
|
||||
assert_eq!(crowdloan::NewRaise::<Test>::get(), empty);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1241,14 +1237,14 @@ mod tests {
|
||||
last_period: 4,
|
||||
fund_index: 0,
|
||||
};
|
||||
assert_eq!(Crowdloan::funds(ParaId::from(0)), Some(fund_info));
|
||||
assert_eq!(crowdloan::Funds::<Test>::get(ParaId::from(0)), Some(fund_info));
|
||||
// User has deposit removed from their free balance
|
||||
assert_eq!(Balances::free_balance(1), 999);
|
||||
// Deposit is placed in reserved
|
||||
assert_eq!(Balances::reserved_balance(1), 1);
|
||||
// No new raise until first contribution
|
||||
let empty: Vec<ParaId> = Vec::new();
|
||||
assert_eq!(Crowdloan::new_raise(), empty);
|
||||
assert_eq!(crowdloan::NewRaise::<Test>::get(), empty);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1321,9 +1317,9 @@ mod tests {
|
||||
// Contributions appear in free balance of crowdloan
|
||||
assert_eq!(Balances::free_balance(Crowdloan::fund_account_id(index)), 49);
|
||||
// Crowdloan is added to NewRaise
|
||||
assert_eq!(Crowdloan::new_raise(), vec![para]);
|
||||
assert_eq!(crowdloan::NewRaise::<Test>::get(), vec![para]);
|
||||
|
||||
let fund = Crowdloan::funds(para).unwrap();
|
||||
let fund = crowdloan::Funds::<Test>::get(para).unwrap();
|
||||
|
||||
// Last contribution time recorded
|
||||
assert_eq!(fund.last_contribution, LastContribution::PreEnding(0));
|
||||
@@ -1418,7 +1414,7 @@ mod tests {
|
||||
assert_eq!(Balances::free_balance(Crowdloan::fund_account_id(index)), 59);
|
||||
|
||||
// Contribution amount is correct
|
||||
let fund = Crowdloan::funds(para).unwrap();
|
||||
let fund = crowdloan::Funds::<Test>::get(para).unwrap();
|
||||
assert_eq!(fund.raised, 59);
|
||||
});
|
||||
}
|
||||
@@ -1570,7 +1566,7 @@ mod tests {
|
||||
);
|
||||
|
||||
// Endings count incremented
|
||||
assert_eq!(Crowdloan::endings_count(), 1);
|
||||
assert_eq!(crowdloan::EndingsCount::<Test>::get(), 1);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1758,7 +1754,7 @@ mod tests {
|
||||
|
||||
// We test the historic case where crowdloan accounts only have one provider:
|
||||
{
|
||||
let fund = Crowdloan::funds(para).unwrap();
|
||||
let fund = crowdloan::Funds::<Test>::get(para).unwrap();
|
||||
let pot = Crowdloan::fund_account_id(fund.fund_index);
|
||||
System::dec_providers(&pot).unwrap();
|
||||
assert_eq!(System::providers(&pot), 1);
|
||||
@@ -1910,10 +1906,10 @@ mod tests {
|
||||
|
||||
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None));
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para_1, 100, None));
|
||||
let old_crowdloan = Crowdloan::funds(para_1).unwrap();
|
||||
let old_crowdloan = crowdloan::Funds::<Test>::get(para_1).unwrap();
|
||||
|
||||
assert_ok!(Crowdloan::edit(RuntimeOrigin::root(), para_1, 1234, 2, 3, 4, None));
|
||||
let new_crowdloan = Crowdloan::funds(para_1).unwrap();
|
||||
let new_crowdloan = crowdloan::Funds::<Test>::get(para_1).unwrap();
|
||||
|
||||
// Some things stay the same
|
||||
assert_eq!(old_crowdloan.depositor, new_crowdloan.depositor);
|
||||
@@ -1974,7 +1970,7 @@ mod tests {
|
||||
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para_1, 100, None));
|
||||
run_to_block(6);
|
||||
assert_ok!(Crowdloan::poke(RuntimeOrigin::signed(1), para_1));
|
||||
assert_eq!(Crowdloan::new_raise(), vec![para_1]);
|
||||
assert_eq!(crowdloan::NewRaise::<Test>::get(), vec![para_1]);
|
||||
assert_noop!(
|
||||
Crowdloan::poke(RuntimeOrigin::signed(1), para_1),
|
||||
Error::<Test>::AlreadyInNewRaise
|
||||
|
||||
@@ -348,7 +348,7 @@ const VALIDATORS: &[Sr25519Keyring] = &[
|
||||
|
||||
fn maybe_new_session(n: u32) {
|
||||
if n % BLOCKS_PER_SESSION == 0 {
|
||||
let session_index = shared::Pallet::<Test>::session_index() + 1;
|
||||
let session_index = shared::CurrentSessionIndex::<Test>::get() + 1;
|
||||
let validators_pub_keys = validators_public_keys(VALIDATORS);
|
||||
|
||||
shared::Pallet::<Test>::set_session_index(session_index);
|
||||
@@ -464,7 +464,7 @@ fn basic_end_to_end_works() {
|
||||
200 + offset, // Block End
|
||||
None,
|
||||
));
|
||||
let fund_2 = Crowdloan::funds(ParaId::from(para_2)).unwrap();
|
||||
let fund_2 = crowdloan::Funds::<Test>::get(ParaId::from(para_2)).unwrap();
|
||||
let crowdloan_account = Crowdloan::fund_account_id(fund_2.fund_index);
|
||||
|
||||
// Auction ending begins on block 100 + offset, so we make a bid before then.
|
||||
@@ -826,7 +826,7 @@ fn competing_bids() {
|
||||
run_to_block(starting_block + 110);
|
||||
|
||||
// Appropriate Paras should have won slots
|
||||
let fund_1 = Crowdloan::funds(ParaId::from(2000)).unwrap();
|
||||
let fund_1 = crowdloan::Funds::<Test>::get(ParaId::from(2000)).unwrap();
|
||||
let crowdloan_1 = Crowdloan::fund_account_id(fund_1.fund_index);
|
||||
assert_eq!(
|
||||
slots::Leases::<Test>::get(ParaId::from(2000)),
|
||||
@@ -912,7 +912,7 @@ fn basic_swap_works() {
|
||||
200, // Block End
|
||||
None,
|
||||
));
|
||||
let fund = Crowdloan::funds(ParaId::from(2000)).unwrap();
|
||||
let fund = crowdloan::Funds::<Test>::get(ParaId::from(2000)).unwrap();
|
||||
let crowdloan_account = Crowdloan::fund_account_id(fund.fund_index);
|
||||
|
||||
// Bunch of contributions
|
||||
@@ -932,7 +932,7 @@ fn basic_swap_works() {
|
||||
// ----------------------------------------- para deposit --- crowdloan
|
||||
let crowdloan_deposit = 100;
|
||||
let para_id_deposit = <Test as paras_registrar::Config>::ParaDeposit::get();
|
||||
let code_deposit = configuration::Pallet::<Test>::config().max_code_size *
|
||||
let code_deposit = configuration::ActiveConfig::<Test>::get().max_code_size *
|
||||
<Test as paras_registrar::Config>::DataDepositPerByte::get();
|
||||
|
||||
// Para 2000 has a genesis head size of 10.
|
||||
@@ -944,16 +944,16 @@ fn basic_swap_works() {
|
||||
assert_eq!(Balances::reserved_balance(&account_id(2)), para_id_deposit + code_deposit + 20);
|
||||
assert_eq!(Balances::reserved_balance(&crowdloan_account), total);
|
||||
// Crowdloan is appropriately set
|
||||
assert!(Crowdloan::funds(ParaId::from(2000)).is_some());
|
||||
assert!(Crowdloan::funds(ParaId::from(2001)).is_none());
|
||||
assert!(crowdloan::Funds::<Test>::get(ParaId::from(2000)).is_some());
|
||||
assert!(crowdloan::Funds::<Test>::get(ParaId::from(2001)).is_none());
|
||||
|
||||
// New leases will start on block 400
|
||||
let lease_start_block = 400;
|
||||
run_to_block(lease_start_block);
|
||||
|
||||
// Slots are won by Para 1
|
||||
assert!(!Slots::lease(ParaId::from(2000)).is_empty());
|
||||
assert!(Slots::lease(ParaId::from(2001)).is_empty());
|
||||
assert!(!slots::Leases::<Test>::get(ParaId::from(2000)).is_empty());
|
||||
assert!(slots::Leases::<Test>::get(ParaId::from(2001)).is_empty());
|
||||
|
||||
// 2 sessions later it is a parachain
|
||||
run_to_block(lease_start_block + 20);
|
||||
@@ -986,11 +986,11 @@ fn basic_swap_works() {
|
||||
assert_eq!(Balances::reserved_balance(&account_id(1)), crowdloan_deposit);
|
||||
assert_eq!(Balances::reserved_balance(&account_id(2)), para_id_deposit + code_deposit + 20);
|
||||
// Crowdloan ownership is swapped
|
||||
assert!(Crowdloan::funds(ParaId::from(2000)).is_none());
|
||||
assert!(Crowdloan::funds(ParaId::from(2001)).is_some());
|
||||
assert!(crowdloan::Funds::<Test>::get(ParaId::from(2000)).is_none());
|
||||
assert!(crowdloan::Funds::<Test>::get(ParaId::from(2001)).is_some());
|
||||
// Slot is swapped
|
||||
assert!(Slots::lease(ParaId::from(2000)).is_empty());
|
||||
assert!(!Slots::lease(ParaId::from(2001)).is_empty());
|
||||
assert!(slots::Leases::<Test>::get(ParaId::from(2000)).is_empty());
|
||||
assert!(!slots::Leases::<Test>::get(ParaId::from(2001)).is_empty());
|
||||
|
||||
// Cant dissolve
|
||||
assert_noop!(
|
||||
@@ -1061,7 +1061,9 @@ fn parachain_swap_works() {
|
||||
assert_eq!(Paras::lifecycle(ParaId::from(2001)), Some(ParaLifecycle::Onboarding));
|
||||
|
||||
assert_eq!(
|
||||
Balances::total_balance(&Crowdloan::fund_account_id(Crowdloan::next_fund_index())),
|
||||
Balances::total_balance(&Crowdloan::fund_account_id(
|
||||
crowdloan::NextFundIndex::<Test>::get()
|
||||
)),
|
||||
0
|
||||
);
|
||||
|
||||
@@ -1090,7 +1092,7 @@ fn parachain_swap_works() {
|
||||
end, // Block End
|
||||
None,
|
||||
));
|
||||
let winner_fund = Crowdloan::funds(ParaId::from(winner)).unwrap();
|
||||
let winner_fund = crowdloan::Funds::<Test>::get(ParaId::from(winner)).unwrap();
|
||||
let crowdloan_account = Crowdloan::fund_account_id(winner_fund.fund_index);
|
||||
|
||||
// Bunch of contributions
|
||||
@@ -1107,7 +1109,7 @@ fn parachain_swap_works() {
|
||||
run_to_block(end);
|
||||
|
||||
// Crowdloan is appropriately set
|
||||
assert!(Crowdloan::funds(ParaId::from(winner)).is_some());
|
||||
assert!(crowdloan::Funds::<Test>::get(ParaId::from(winner)).is_some());
|
||||
|
||||
// New leases will start on block lease period index * 100
|
||||
let lease_start_block = lease_period_index_start * 100;
|
||||
@@ -1116,8 +1118,8 @@ fn parachain_swap_works() {
|
||||
|
||||
start_auction(4u32, 2000, 200);
|
||||
// Slots are won by Para 1
|
||||
assert!(!Slots::lease(ParaId::from(2000)).is_empty());
|
||||
assert!(Slots::lease(ParaId::from(2001)).is_empty());
|
||||
assert!(!slots::Leases::<Test>::get(ParaId::from(2000)).is_empty());
|
||||
assert!(slots::Leases::<Test>::get(ParaId::from(2001)).is_empty());
|
||||
|
||||
// 2 sessions later it is a parachain
|
||||
run_to_block(4 * 100 + 20);
|
||||
@@ -1127,8 +1129,8 @@ fn parachain_swap_works() {
|
||||
// Let's repeat the process now for another parachain.
|
||||
start_auction(6u32, 2001, 500);
|
||||
// Slots are won by Para 1
|
||||
assert!(!Slots::lease(ParaId::from(2000)).is_empty());
|
||||
assert!(!Slots::lease(ParaId::from(2001)).is_empty());
|
||||
assert!(!slots::Leases::<Test>::get(ParaId::from(2000)).is_empty());
|
||||
assert!(!slots::Leases::<Test>::get(ParaId::from(2001)).is_empty());
|
||||
|
||||
// 2 sessions later it is a parachain
|
||||
run_to_block(6 * 100 + 20);
|
||||
@@ -1145,22 +1147,22 @@ fn parachain_swap_works() {
|
||||
assert_eq!(slots::Leases::<Test>::get(ParaId::from(2000)).len(), 6);
|
||||
assert_eq!(slots::Leases::<Test>::get(ParaId::from(2001)).len(), 8);
|
||||
|
||||
let fund_2000 = Crowdloan::funds(ParaId::from(2000)).unwrap();
|
||||
let fund_2000 = crowdloan::Funds::<Test>::get(ParaId::from(2000)).unwrap();
|
||||
assert_eq!(fund_2000.fund_index, 0);
|
||||
assert_eq!(
|
||||
Balances::reserved_balance(&Crowdloan::fund_account_id(fund_2000.fund_index)),
|
||||
fund_2000.raised
|
||||
);
|
||||
|
||||
let fund_2001 = Crowdloan::funds(ParaId::from(2001)).unwrap();
|
||||
let fund_2001 = crowdloan::Funds::<Test>::get(ParaId::from(2001)).unwrap();
|
||||
assert_eq!(fund_2001.fund_index, 1);
|
||||
assert_eq!(
|
||||
Balances::reserved_balance(&Crowdloan::fund_account_id(fund_2001.fund_index)),
|
||||
fund_2001.raised
|
||||
);
|
||||
|
||||
assert_eq!(Slots::lease(ParaId::from(2000)).len(), 6);
|
||||
assert_eq!(Slots::lease(ParaId::from(2001)).len(), 8);
|
||||
assert_eq!(slots::Leases::<Test>::get(ParaId::from(2000)).len(), 6);
|
||||
assert_eq!(slots::Leases::<Test>::get(ParaId::from(2001)).len(), 8);
|
||||
|
||||
// Now we swap them.
|
||||
assert_ok!(Registrar::swap(
|
||||
@@ -1182,14 +1184,14 @@ fn parachain_swap_works() {
|
||||
));
|
||||
|
||||
// Crowdloan Swapped
|
||||
let fund_2000 = Crowdloan::funds(ParaId::from(2000)).unwrap();
|
||||
let fund_2000 = crowdloan::Funds::<Test>::get(ParaId::from(2000)).unwrap();
|
||||
assert_eq!(fund_2000.fund_index, 1);
|
||||
assert_eq!(
|
||||
Balances::reserved_balance(&Crowdloan::fund_account_id(fund_2000.fund_index)),
|
||||
fund_2000.raised
|
||||
);
|
||||
|
||||
let fund_2001 = Crowdloan::funds(ParaId::from(2001)).unwrap();
|
||||
let fund_2001 = crowdloan::Funds::<Test>::get(ParaId::from(2001)).unwrap();
|
||||
assert_eq!(fund_2001.fund_index, 0);
|
||||
assert_eq!(
|
||||
Balances::reserved_balance(&Crowdloan::fund_account_id(fund_2001.fund_index)),
|
||||
@@ -1197,8 +1199,8 @@ fn parachain_swap_works() {
|
||||
);
|
||||
|
||||
// Slots Swapped
|
||||
assert_eq!(Slots::lease(ParaId::from(2000)).len(), 8);
|
||||
assert_eq!(Slots::lease(ParaId::from(2001)).len(), 6);
|
||||
assert_eq!(slots::Leases::<Test>::get(ParaId::from(2000)).len(), 8);
|
||||
assert_eq!(slots::Leases::<Test>::get(ParaId::from(2001)).len(), 6);
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1263,7 +1265,7 @@ fn crowdloan_ending_period_bid() {
|
||||
200, // Block End
|
||||
None,
|
||||
));
|
||||
let fund = Crowdloan::funds(ParaId::from(2000)).unwrap();
|
||||
let fund = crowdloan::Funds::<Test>::get(ParaId::from(2000)).unwrap();
|
||||
let crowdloan_account = Crowdloan::fund_account_id(fund.fund_index);
|
||||
|
||||
// Bunch of contributions
|
||||
@@ -1297,7 +1299,7 @@ fn crowdloan_ending_period_bid() {
|
||||
winning[SlotRange::ZeroThree as u8 as usize] =
|
||||
Some((crowdloan_account.clone(), ParaId::from(2000), total));
|
||||
|
||||
assert_eq!(Auctions::winning(0), Some(winning));
|
||||
assert_eq!(auctions::Winning::<Test>::get(0), Some(winning));
|
||||
|
||||
run_to_block(ends_at + 1);
|
||||
|
||||
@@ -1310,7 +1312,7 @@ fn crowdloan_ending_period_bid() {
|
||||
winning[SlotRange::ZeroOne as u8 as usize] = Some((account_id(2), ParaId::from(2001), 900));
|
||||
winning[SlotRange::ZeroThree as u8 as usize] =
|
||||
Some((crowdloan_account.clone(), ParaId::from(2000), total + 900));
|
||||
assert_eq!(Auctions::winning(2), Some(winning));
|
||||
assert_eq!(auctions::Winning::<Test>::get(2), Some(winning));
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1615,7 +1617,7 @@ fn cant_bid_on_existing_lease_periods() {
|
||||
400, // Long block end
|
||||
None,
|
||||
));
|
||||
let fund = Crowdloan::funds(ParaId::from(2000)).unwrap();
|
||||
let fund = crowdloan::Funds::<Test>::get(ParaId::from(2000)).unwrap();
|
||||
let crowdloan_account = Crowdloan::fund_account_id(fund.fund_index);
|
||||
|
||||
// Bunch of contributions
|
||||
@@ -1656,7 +1658,7 @@ fn cant_bid_on_existing_lease_periods() {
|
||||
|
||||
// Poke the crowdloan into `NewRaise`
|
||||
assert_ok!(Crowdloan::poke(signed(1), ParaId::from(2000)));
|
||||
assert_eq!(Crowdloan::new_raise(), vec![ParaId::from(2000)]);
|
||||
assert_eq!(crowdloan::NewRaise::<Test>::get(), vec![ParaId::from(2000)]);
|
||||
|
||||
// Beginning of ending block.
|
||||
run_to_block(starting_block + 100);
|
||||
|
||||
@@ -462,7 +462,7 @@ impl<T: Config> Registrar for Pallet<T> {
|
||||
// All lease holding parachains. Ordered ascending by ParaId. On-demand parachains are not
|
||||
// included.
|
||||
fn parachains() -> Vec<ParaId> {
|
||||
paras::Pallet::<T>::parachains()
|
||||
paras::Parachains::<T>::get()
|
||||
}
|
||||
|
||||
// Return if a para is a parathread (on-demand parachain)
|
||||
@@ -530,14 +530,14 @@ impl<T: Config> Registrar for Pallet<T> {
|
||||
|
||||
#[cfg(any(feature = "runtime-benchmarks", test))]
|
||||
fn worst_head_data() -> HeadData {
|
||||
let max_head_size = configuration::Pallet::<T>::config().max_head_data_size;
|
||||
let max_head_size = configuration::ActiveConfig::<T>::get().max_head_data_size;
|
||||
assert!(max_head_size > 0, "max_head_data can't be zero for generating worst head data.");
|
||||
vec![0u8; max_head_size as usize].into()
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "runtime-benchmarks", test))]
|
||||
fn worst_validation_code() -> ValidationCode {
|
||||
let max_code_size = configuration::Pallet::<T>::config().max_code_size;
|
||||
let max_code_size = configuration::ActiveConfig::<T>::get().max_code_size;
|
||||
assert!(max_code_size > 0, "max_code_size can't be zero for generating worst code data.");
|
||||
let validation_code = vec![0u8; max_code_size as usize];
|
||||
validation_code.into()
|
||||
@@ -667,7 +667,7 @@ impl<T: Config> Pallet<T> {
|
||||
validation_code: ValidationCode,
|
||||
para_kind: ParaKind,
|
||||
) -> Result<(ParaGenesisArgs, BalanceOf<T>), sp_runtime::DispatchError> {
|
||||
let config = configuration::Pallet::<T>::config();
|
||||
let config = configuration::ActiveConfig::<T>::get();
|
||||
ensure!(validation_code.0.len() >= MIN_CODE_SIZE as usize, Error::<T>::InvalidCode);
|
||||
ensure!(validation_code.0.len() <= config.max_code_size as usize, Error::<T>::CodeTooLarge);
|
||||
ensure!(
|
||||
@@ -915,7 +915,7 @@ mod tests {
|
||||
}
|
||||
// Session change every 3 blocks.
|
||||
if (b + 1) % BLOCKS_PER_SESSION == 0 {
|
||||
let session_index = shared::Pallet::<Test>::session_index() + 1;
|
||||
let session_index = shared::CurrentSessionIndex::<Test>::get() + 1;
|
||||
let validators_pub_keys = VALIDATORS.iter().map(|v| v.public().into()).collect();
|
||||
|
||||
shared::Pallet::<Test>::set_session_index(session_index);
|
||||
@@ -947,11 +947,11 @@ mod tests {
|
||||
}
|
||||
|
||||
fn max_code_size() -> u32 {
|
||||
Configuration::config().max_code_size
|
||||
configuration::ActiveConfig::<Test>::get().max_code_size
|
||||
}
|
||||
|
||||
fn max_head_size() -> u32 {
|
||||
Configuration::config().max_head_data_size
|
||||
configuration::ActiveConfig::<Test>::get().max_head_data_size
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -146,9 +146,9 @@ pub mod pallet {
|
||||
xcm: Box<xcm::opaque::VersionedXcm>,
|
||||
) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
ensure!(<paras::Pallet<T>>::is_valid_para(id), Error::<T>::ParaDoesntExist);
|
||||
let config = <configuration::Pallet<T>>::config();
|
||||
<dmp::Pallet<T>>::queue_downward_message(&config, id, xcm.encode()).map_err(|e| match e
|
||||
ensure!(paras::Pallet::<T>::is_valid_para(id), Error::<T>::ParaDoesntExist);
|
||||
let config = configuration::ActiveConfig::<T>::get();
|
||||
dmp::Pallet::<T>::queue_downward_message(&config, id, xcm.encode()).map_err(|e| match e
|
||||
{
|
||||
dmp::QueueDownwardMessageError::ExceedsMaxMessageSize =>
|
||||
Error::<T>::ExceedsMaxMessageSize.into(),
|
||||
@@ -170,13 +170,13 @@ pub mod pallet {
|
||||
) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
|
||||
<hrmp::Pallet<T>>::init_open_channel(
|
||||
hrmp::Pallet::<T>::init_open_channel(
|
||||
sender,
|
||||
recipient,
|
||||
max_capacity,
|
||||
max_message_size,
|
||||
)?;
|
||||
<hrmp::Pallet<T>>::accept_open_channel(recipient, sender)?;
|
||||
hrmp::Pallet::<T>::accept_open_channel(recipient, sender)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,6 @@ pub mod pallet {
|
||||
///
|
||||
/// It is illegal for a `None` value to trail in the list.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn lease)]
|
||||
pub type Leases<T: Config> =
|
||||
StorageMap<_, Twox64Concat, ParaId, Vec<Option<(T::AccountId, BalanceOf<T>)>>, ValueQuery>;
|
||||
|
||||
|
||||
@@ -116,11 +116,11 @@ where
|
||||
|
||||
// Downward message passing.
|
||||
let xcm = msg.take().ok_or(MissingArgument)?;
|
||||
let config = <configuration::Pallet<T>>::config();
|
||||
let config = configuration::ActiveConfig::<T>::get();
|
||||
let para = id.into();
|
||||
let price = P::price_for_delivery(para, &xcm);
|
||||
let blob = W::wrap_version(&d, xcm).map_err(|()| DestinationUnsupported)?.encode();
|
||||
<dmp::Pallet<T>>::can_queue_downward_message(&config, ¶, &blob)
|
||||
dmp::Pallet::<T>::can_queue_downward_message(&config, ¶, &blob)
|
||||
.map_err(Into::<SendError>::into)?;
|
||||
|
||||
Ok(((config, para, blob), price))
|
||||
@@ -130,7 +130,7 @@ where
|
||||
(config, para, blob): (HostConfiguration<BlockNumberFor<T>>, ParaId, Vec<u8>),
|
||||
) -> Result<XcmHash, SendError> {
|
||||
let hash = sp_io::hashing::blake2_256(&blob[..]);
|
||||
<dmp::Pallet<T>>::queue_downward_message(&config, para, blob)
|
||||
dmp::Pallet::<T>::queue_downward_message(&config, para, blob)
|
||||
.map(|()| hash)
|
||||
.map_err(|_| SendError::Transport(&"Error placing into DMP queue"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user