Skip to content

Commit

Permalink
Add broker pallet to coretime-westend (#3272)
Browse files Browse the repository at this point in the history
This brings functionality to Westend's Coretime Chain runtime, where
previously it was not much more than a shell.

It is assumed that the Coretime pallet will have the same index in the
Westend runtime as it does in Rococo for the runtime calls.

TODO:
- [x] Generate chainspec
- [x] Regenerate weights
- [x] Check hardcoded RuntimeCall weights against relay weights for
transacts

Aura key generation: paritytech/devops#2725

---------

Co-authored-by: command-bot <>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Anton Vilhelm Ásgeirsson <antonva@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 16, 2024
1 parent 34352e8 commit 9923444
Show file tree
Hide file tree
Showing 36 changed files with 1,967 additions and 987 deletions.
4 changes: 1 addition & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions cumulus/parachains/chain-specs/coretime-westend.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ sp-version = { path = "../../../../../substrate/primitives/version", default-fea
# Polkadot
pallet-xcm = { path = "../../../../../polkadot/xcm/pallet-xcm", default-features = false }
pallet-xcm-benchmarks = { path = "../../../../../polkadot/xcm/pallet-xcm-benchmarks", default-features = false, optional = true }
polkadot-core-primitives = { path = "../../../../../polkadot/core-primitives", default-features = false }
polkadot-parachain-primitives = { path = "../../../../../polkadot/parachain", default-features = false }
polkadot-runtime-common = { path = "../../../../../polkadot/runtime/common", default-features = false }
rococo-runtime-constants = { path = "../../../../../polkadot/runtime/rococo/constants", default-features = false }
Expand Down Expand Up @@ -115,7 +114,6 @@ std = [
"pallet-xcm/std",
"parachain-info/std",
"parachains-common/std",
"polkadot-core-primitives/std",
"polkadot-parachain-primitives/std",
"polkadot-runtime-common/std",
"rococo-runtime-constants/std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ use pallet_broker::{CoreAssignment, CoreIndex, CoretimeInterface, PartsOf57600,
use parachains_common::{AccountId, Balance, BlockNumber};
use xcm::latest::prelude::*;

// TODO: check AccountId import
pub struct CreditToCollatorPot;
impl OnUnbalanced<Credit<AccountId, Balances>> for CreditToCollatorPot {
fn on_nonzero_unbalanced(credit: Credit<polkadot_core_primitives::AccountId, Balances>) {
fn on_nonzero_unbalanced(credit: Credit<AccountId, Balances>) {
let staking_pot = CollatorSelection::account_id();
let _ = <Balances as Balanced<_>>::resolve(&staking_pot, credit);
}
Expand Down Expand Up @@ -81,7 +80,7 @@ pub struct CoretimeAllocator;
impl CoretimeInterface for CoretimeAllocator {
type AccountId = AccountId;
type Balance = Balance;
type RealyChainBlockNumberProvider = RelaychainDataProvider<Runtime>;
type RelayChainBlockNumberProvider = RelaychainDataProvider<Runtime>;

fn request_core_count(count: CoreIndex) {
use crate::coretime::CoretimeProviderCalls::RequestCoreCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl<Call> XcmWeightInfo<Call> for CoretimeRococoXcmWeight<Call> {
XcmGeneric::<Runtime>::clear_transact_status()
}
fn universal_origin(_: &Junction) -> Weight {
XcmGeneric::<Runtime>::universal_origin()
Weight::MAX
}
fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight {
Weight::MAX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,16 +312,6 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Minimum execution time: 2_082_000 picoseconds.
Weight::from_parts(2_144_000, 0)
}
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
pub fn universal_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `1489`
// Minimum execution time: 4_275_000 picoseconds.
Weight::from_parts(4_381_000, 1489)
.saturating_add(T::DbWeight::get().reads(1))
}
pub fn set_fees_mode() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
Expand Down
12 changes: 6 additions & 6 deletions cumulus/parachains/runtimes/coretime/coretime-westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ pallet-aura = { path = "../../../../../substrate/frame/aura", default-features =
pallet-authorship = { path = "../../../../../substrate/frame/authorship", default-features = false }
pallet-balances = { path = "../../../../../substrate/frame/balances", default-features = false }
pallet-message-queue = { path = "../../../../../substrate/frame/message-queue", default-features = false }
pallet-broker = { path = "../../../../../substrate/frame/broker", default-features = false }
pallet-multisig = { path = "../../../../../substrate/frame/multisig", default-features = false }
pallet-session = { path = "../../../../../substrate/frame/session", default-features = false }
pallet-sudo = { path = "../../../../../substrate/frame/sudo", default-features = false }
pallet-timestamp = { path = "../../../../../substrate/frame/timestamp", default-features = false }
pallet-transaction-payment = { path = "../../../../../substrate/frame/transaction-payment", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { path = "../../../../../substrate/frame/transaction-payment/rpc/runtime-api", default-features = false }
Expand All @@ -55,7 +55,6 @@ sp-version = { path = "../../../../../substrate/primitives/version", default-fea
# Polkadot
pallet-xcm = { path = "../../../../../polkadot/xcm/pallet-xcm", default-features = false }
pallet-xcm-benchmarks = { path = "../../../../../polkadot/xcm/pallet-xcm-benchmarks", default-features = false, optional = true }
polkadot-core-primitives = { path = "../../../../../polkadot/core-primitives", default-features = false }
polkadot-parachain-primitives = { path = "../../../../../polkadot/parachain", default-features = false }
polkadot-runtime-common = { path = "../../../../../polkadot/runtime/common", default-features = false }
westend-runtime-constants = { path = "../../../../../polkadot/runtime/westend/constants", default-features = false }
Expand Down Expand Up @@ -100,11 +99,11 @@ std = [
"pallet-aura/std",
"pallet-authorship/std",
"pallet-balances/std",
"pallet-broker/std",
"pallet-collator-selection/std",
"pallet-message-queue/std",
"pallet-multisig/std",
"pallet-session/std",
"pallet-sudo/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
Expand All @@ -113,7 +112,6 @@ std = [
"pallet-xcm/std",
"parachain-info/std",
"parachains-common/std",
"polkadot-core-primitives/std",
"polkadot-parachain-primitives/std",
"polkadot-runtime-common/std",
"scale-info/std",
Expand Down Expand Up @@ -150,10 +148,10 @@ runtime-benchmarks = [
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-broker/runtime-benchmarks",
"pallet-collator-selection/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-xcm-benchmarks/runtime-benchmarks",
Expand All @@ -178,11 +176,11 @@ try-runtime = [
"pallet-aura/try-runtime",
"pallet-authorship/try-runtime",
"pallet-balances/try-runtime",
"pallet-broker/try-runtime",
"pallet-collator-selection/try-runtime",
"pallet-message-queue/try-runtime",
"pallet-multisig/try-runtime",
"pallet-session/try-runtime",
"pallet-sudo/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-utility/try-runtime",
Expand All @@ -193,3 +191,5 @@ try-runtime = [
]

experimental = ["pallet-aura/experimental"]

fast-runtime = []
10 changes: 9 additions & 1 deletion cumulus/parachains/runtimes/coretime/coretime-westend/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ fn main() {
.with_current_project()
.export_heap_base()
.import_memory()
.build()
.build();

substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.set_file_name("fast_runtime_binary.rs")
.enable_feature("fast-runtime")
.import_memory()
.export_heap_base()
.build();
}

#[cfg(not(feature = "std"))]
Expand Down
Loading

0 comments on commit 9923444

Please sign in to comment.