Skip to content

Commit

Permalink
Cancel auctions on Coretime launch (#215)
Browse files Browse the repository at this point in the history
Parachain Auctions that would conclude after Coretime launch, would not
be served, yet we are cancelling all auctions that are still ongoing.

- [ ] Does not require a CHANGELOG entry

---------

Co-authored-by: eskimor <[email protected]>
Co-authored-by: joe petrowski <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
  • Loading branch information
4 people authored Mar 8, 2024
1 parent 36a7ea1 commit 6d56c21
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/check-migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
echo "Flags: $EXTRA_FLAGS"
./try-runtime \
RUST_LOG=runtime=DEBUG ./try-runtime \
--runtime $RUNTIME_BLOB_PATH \
on-runtime-upgrade --checks=pre-and-post \
$EXTRA_FLAGS \
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Feature for enabling debug prints in the Polkadot and Kusama runtime ([polkadot-fellows/runtimes#85](https://github.com/polkadot-fellows/runtimes/pull/85))
- Added new "Wish for Change" track ([polkadot-fellows/runtimes#184](https://github.com/polkadot-fellows/runtimes/pull/184))
- Enable Coretime and on-demand on Kusama ([polkadot-fellows/runtimes#159](https://github.com/polkadot-fellows/runtimes/pull/159)
- Cancel Parachain Auctions [polkadot-fellows/runtimes#215](https://github.com/polkadot-fellows/runtimes/pull/215)

### Changed

Expand Down
39 changes: 39 additions & 0 deletions relay/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,9 @@ pub type Migrations = (migrations::Unreleased, migrations::Permanent);
#[allow(deprecated, missing_docs)]
pub mod migrations {
use super::*;
use frame_support::traits::OnRuntimeUpgrade;
use pallet_scheduler::WeightInfo as SchedulerWeightInfo;
use runtime_common::auctions::WeightInfo as AuctionsWeightInfo;
#[cfg(feature = "try-runtime")]
use sp_core::crypto::ByteArray;

Expand Down Expand Up @@ -1849,6 +1852,41 @@ pub mod migrations {
}
}

/// Cancel all ongoing auctions.
///
/// Any leases that come into existence after coretime was launched will not be served. Yet,
/// any ongoing auctions must be cancelled.
///
/// Safety:
///
/// - After coretime is launched, there are no auctions anymore. So if this forgotten to
/// be removed after the runtime upgrade, running this again on the next one is harmless.
/// - I am assuming scheduler `TaskName`s are unique, so removal of the scheduled entry
/// multiple times should also be fine.
pub struct CancelAuctions;
impl OnRuntimeUpgrade for CancelAuctions {
fn on_runtime_upgrade() -> Weight {
if let Err(err) = Auctions::cancel_auction(frame_system::RawOrigin::Root.into()) {
log::debug!(target: "runtime", "Cancelling auctions failed: {:?}", err);
}
// Cancel scheduled auction as well:
if let Err(err) = Scheduler::cancel_named(
pallet_custom_origins::Origin::AuctionAdmin.into(),
[
0x5c, 0x68, 0xbf, 0x0c, 0x2d, 0x11, 0x04, 0x91, 0x6b, 0xa5, 0xa4, 0xde, 0xe6,
0xb8, 0x14, 0xe8, 0x2b, 0x27, 0x93, 0x78, 0x4c, 0xb6, 0xe7, 0x69, 0x04, 0x00,
0x1a, 0x59, 0x49, 0xc1, 0x63, 0xb1,
],
) {
log::debug!(target: "runtime", "Cancelling scheduled auctions failed: {:?}", err);
}
weights::runtime_common_auctions::WeightInfo::<Runtime>::cancel_auction()
.saturating_add(weights::pallet_scheduler::WeightInfo::<Runtime>::cancel_named(
<Runtime as pallet_scheduler::Config>::MaxScheduledPerBlock::get(),
))
}
}

/// Unreleased migrations. Add new ones here:
pub type Unreleased = (
pallet_nomination_pools::migration::versioned::V7ToV8<Runtime>,
Expand All @@ -1872,6 +1910,7 @@ pub mod migrations {
ImOnlinePalletName,
<Runtime as frame_system::Config>::DbWeight,
>,
CancelAuctions,
);

/// Migrations/checks that do not need to be versioned and can run on every update.
Expand Down

0 comments on commit 6d56c21

Please sign in to comment.