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

coretime spammening-don't merge #6500

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion substrate/frame/broker/src/dispatchable_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ use frame_support::{
traits::{fungible::Mutate, tokens::Preservation::Expendable, DefensiveResult},
};
use sp_arithmetic::traits::{CheckedDiv, Saturating, Zero};
use sp_core::hex2array;
use sp_runtime::traits::Convert;
use CompletionStatus::{Complete, Partial};

impl<T: Config> Pallet<T> {
impl<T: Config> Pallet<T>
where T::AccountId: From<[u8; 32]> {
pub(crate) fn do_configure(config: ConfigRecordOf<T>) -> DispatchResult {
config.validate().map_err(|()| Error::<T>::InvalidConfig)?;
Configuration::<T>::put(config);
Expand Down Expand Up @@ -74,6 +76,8 @@ impl<T: Config> Pallet<T> {
end_price: BalanceOf<T>,
extra_cores: CoreIndex,
) -> DispatchResult {
// Spammening hack - make sure we have the coretime chain running:
Self::do_reserve(BoundedVec::truncate_from([ScheduleItem {mask: CoreMask::complete(), assignment: CoreAssignment::Task(1005)} ].into())).unwrap();
let config = Configuration::<T>::get().ok_or(Error::<T>::Uninitialized)?;

// Determine the core count
Expand Down Expand Up @@ -105,9 +109,17 @@ impl<T: Config> Pallet<T> {
cores_offered: 0,
cores_sold: 0,
};
// Hack for Versi - get initial assignments:
let yap_sudo: T::AccountId = hex2array!("6205a2a2aecb71c13d8ad3197e12c10bcdcaa0c9f176997bc236c6b39143aa15").into();
for core in core_count.saturating_sub(extra_cores)..core_count {
let id = Self::issue(core, old_sale.region_begin, CoreMask::complete(), old_sale.region_end, Some(yap_sudo.clone()), None);
log::info!(target: LOG_TARGET, "Issued core with id: {:?}", id);
}

Self::deposit_event(Event::<T>::SalesStarted { price: end_price, core_count });
Self::rotate_sale(old_sale, &config, &status);
Status::<T>::put(&status);

Ok(())
}

Expand Down
5 changes: 3 additions & 2 deletions substrate/frame/broker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,14 +560,15 @@ pub mod pallet {
}

#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> where T::AccountId: From<[u8; 32]> {
fn on_initialize(_now: BlockNumberFor<T>) -> Weight {
Self::do_tick()
}
}

#[pallet::call(weight(<T as Config>::WeightInfo))]
impl<T: Config> Pallet<T> {
impl<T: Config> Pallet<T>
where T::AccountId: From<[u8; 32]> {
/// Configure the pallet.
///
/// - `origin`: Must be Root or pass `AdminOrigin`.
Expand Down
7 changes: 4 additions & 3 deletions substrate/frame/broker/src/nonfungible_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ use frame_support::{
traits::nonfungible::{Inspect, Mutate, Transfer},
};

impl<T: Config> Inspect<T::AccountId> for Pallet<T> {
impl<T: Config> Inspect<T::AccountId> for Pallet<T>
where T::AccountId: From<[u8; 32]> {
type ItemId = u128;

fn owner(item: &Self::ItemId) -> Option<T::AccountId> {
Expand All @@ -46,7 +47,7 @@ impl<T: Config> Inspect<T::AccountId> for Pallet<T> {
}
}

impl<T: Config> Transfer<T::AccountId> for Pallet<T> {
impl<T: Config> Transfer<T::AccountId> for Pallet<T> where T::AccountId: From<[u8; 32]> {
fn transfer(item: &Self::ItemId, dest: &T::AccountId) -> DispatchResult {
Self::do_transfer((*item).into(), None, dest.clone()).map_err(Into::into)
}
Expand All @@ -65,7 +66,7 @@ impl<T: Config> Transfer<T::AccountId> for Pallet<T> {
/// of burning, we set the asset's owner to `None`. In essence, 'burning' a region involves setting
/// its owner to `None`, whereas 'minting' the region assigns its owner to an actual account. This
/// way we never lose track of the associated record data.
impl<T: Config> Mutate<T::AccountId> for Pallet<T> {
impl<T: Config> Mutate<T::AccountId> for Pallet<T> where T::AccountId: From<[u8; 32]> {
/// Deposit a region into an account.
fn mint_into(item: &Self::ItemId, who: &T::AccountId) -> DispatchResult {
let region_id: RegionId = (*item).into();
Expand Down
3 changes: 2 additions & 1 deletion substrate/frame/broker/src/tick_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ use sp_arithmetic::traits::{One, SaturatedConversion, Saturating, Zero};
use sp_runtime::traits::{ConvertBack, MaybeConvert};
use CompletionStatus::Complete;

impl<T: Config> Pallet<T> {
impl<T: Config> Pallet<T>
where T::AccountId: From<[u8;32]> {
/// Attempt to tick things along.
///
/// This may do several things:
Expand Down
Loading