Coretime Zombienet test (#2867)

This adds a Zombienet test for Coretime.

Requires: https://github.com/paritytech/polkadot-sdk/pull/2862

---------

Co-authored-by: Javier Viola <javier@parity.io>
Co-authored-by: Javier Viola <363911+pepoviola@users.noreply.github.com>
This commit is contained in:
Bastian Köcher
2024-01-08 18:41:02 +00:00
committed by GitHub
parent 1914775bd4
commit 4fdab499c4
11 changed files with 118 additions and 71 deletions
@@ -194,3 +194,5 @@ try-runtime = [
]
experimental = ["pallet-aura/experimental"]
fast-runtime = []
@@ -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"))]
@@ -17,6 +17,7 @@
use crate::*;
use codec::{Decode, Encode};
use cumulus_pallet_parachain_system::RelaychainDataProvider;
use cumulus_primitives_core::relay_chain;
use frame_support::{
parameter_types,
traits::{
@@ -51,11 +52,16 @@ enum CoretimeProviderCalls {
#[codec(index = 1)]
RequestCoreCount(CoreIndex),
#[codec(index = 2)]
RequestRevenueInfoAt(BlockNumber),
RequestRevenueInfoAt(relay_chain::BlockNumber),
#[codec(index = 3)]
CreditAccount(AccountId, Balance),
#[codec(index = 4)]
AssignCore(CoreIndex, BlockNumber, Vec<(CoreAssignment, PartsOf57600)>, Option<BlockNumber>),
AssignCore(
CoreIndex,
relay_chain::BlockNumber,
Vec<(CoreAssignment, PartsOf57600)>,
Option<relay_chain::BlockNumber>,
),
}
parameter_types! {
@@ -181,7 +187,7 @@ impl CoretimeInterface for CoretimeAllocator {
},
Instruction::Transact {
origin_kind: OriginKind::Native,
require_weight_at_most: Weight::from_parts(1000000000, 200000),
require_weight_at_most: Weight::from_parts(1_000_000_000, 200000),
call: assign_core_call.encode().into(),
},
]);
@@ -215,6 +221,9 @@ impl pallet_broker::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type OnRevenue = CreditToCollatorPot;
#[cfg(feature = "fast-runtime")]
type TimeslicePeriod = ConstU32<10>;
#[cfg(not(feature = "fast-runtime"))]
type TimeslicePeriod = ConstU32<80>;
type MaxLeasedCores = ConstU32<50>;
type MaxReservedCores = ConstU32<10>;
@@ -21,6 +21,14 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
/// Provides the `WASM_BINARY` build with `fast-runtime` feature enabled.
///
/// This is for example useful for local test chains.
#[cfg(feature = "std")]
pub mod fast_runtime_binary {
include!(concat!(env!("OUT_DIR"), "/fast_runtime_binary.rs"));
}
mod coretime;
mod weights;
pub mod xcm_config;
@@ -20,7 +20,7 @@ use sc_chain_spec::{ChainSpec, ChainType};
use std::{borrow::Cow, str::FromStr};
/// Collects all supported Coretime configurations.
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum CoretimeRuntimeType {
// Live
Rococo,
@@ -85,13 +85,13 @@ impl CoretimeRuntimeType {
&include_bytes!("../../../parachains/chain-specs/coretime-rococo.json")[..],
)?)),
CoretimeRuntimeType::RococoLocal =>
Ok(Box::new(rococo::local_config(self, "rococo-local"))),
Ok(Box::new(rococo::local_config(*self, "rococo-local"))),
CoretimeRuntimeType::RococoDevelopment =>
Ok(Box::new(rococo::local_config(self, "rococo-dev"))),
Ok(Box::new(rococo::local_config(*self, "rococo-dev"))),
CoretimeRuntimeType::WestendLocal =>
Ok(Box::new(westend::local_config(self, "westend-local"))),
Ok(Box::new(westend::local_config(*self, "westend-local"))),
CoretimeRuntimeType::WestendDevelopment =>
Ok(Box::new(westend::local_config(self, "westend-dev"))),
Ok(Box::new(westend::local_config(*self, "westend-dev"))),
}
}
}
@@ -114,6 +114,7 @@ pub mod rococo {
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION,
};
use parachains_common::{AccountId, AuraId, Balance};
use sc_chain_spec::ChainType;
use sp_core::sr25519;
pub(crate) const CORETIME_ROCOCO: &str = "coretime-rococo";
@@ -121,24 +122,31 @@ pub mod rococo {
pub(crate) const CORETIME_ROCOCO_DEVELOPMENT: &str = "coretime-rococo-dev";
const CORETIME_ROCOCO_ED: Balance = parachains_common::rococo::currency::EXISTENTIAL_DEPOSIT;
pub fn local_config(runtime_type: &CoretimeRuntimeType, relay_chain: &str) -> GenericChainSpec {
pub fn local_config(runtime_type: CoretimeRuntimeType, relay_chain: &str) -> GenericChainSpec {
// Rococo defaults
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 42.into());
properties.insert("tokenSymbol".into(), "ROC".into());
properties.insert("tokenDecimals".into(), 12.into());
let chain_type = runtime_type.clone().into();
let chain_type = runtime_type.into();
let chain_name = format!("Coretime Rococo {}", chain_type_name(&chain_type));
let para_id = super::CORETIME_PARA_ID;
GenericChainSpec::builder(
let wasm_binary = if matches!(chain_type, ChainType::Local | ChainType::Development) {
coretime_rococo_runtime::fast_runtime_binary::WASM_BINARY
.expect("WASM binary was not built, please build it!")
} else {
coretime_rococo_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
.expect("WASM binary was not built, please build it!")
};
GenericChainSpec::builder(
wasm_binary,
Extensions { relay_chain: relay_chain.to_string(), para_id: para_id.into() },
)
.with_name(&chain_name)
.with_id(runtime_type.clone().into())
.with_id(runtime_type.into())
.with_chain_type(chain_type)
.with_genesis_config_patch(genesis(
// initial collators.
@@ -209,14 +217,14 @@ pub mod westend {
pub(crate) const CORETIME_WESTEND_DEVELOPMENT: &str = "coretime-westend-dev";
const CORETIME_WESTEND_ED: Balance = parachains_common::westend::currency::EXISTENTIAL_DEPOSIT;
pub fn local_config(runtime_type: &CoretimeRuntimeType, relay_chain: &str) -> GenericChainSpec {
pub fn local_config(runtime_type: CoretimeRuntimeType, relay_chain: &str) -> GenericChainSpec {
// westend defaults
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 42.into());
properties.insert("tokenSymbol".into(), "WND".into());
properties.insert("tokenDecimals".into(), 12.into());
let chain_type = runtime_type.clone().into();
let chain_type = runtime_type.into();
let chain_name = format!("Coretime Westend {}", chain_type_name(&chain_type));
let para_id = super::CORETIME_PARA_ID;
@@ -226,7 +234,7 @@ pub mod westend {
Extensions { relay_chain: relay_chain.to_string(), para_id: para_id.into() },
)
.with_name(&chain_name)
.with_id(runtime_type.clone().into())
.with_id(runtime_type.into())
.with_chain_type(chain_type)
.with_genesis_config_patch(genesis(
// initial collators.