mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-20 17:25:41 +00:00
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:
@@ -27,7 +27,8 @@ use pallet_broker::{CoreAssignment, CoreIndex as BrokerCoreIndex};
|
||||
use primitives::{CoreIndex, Id as ParaId};
|
||||
use sp_arithmetic::traits::SaturatedConversion;
|
||||
use xcm::v3::{
|
||||
send_xcm, Instruction, Junction, Junctions, MultiLocation, OriginKind, SendXcm, Xcm,
|
||||
send_xcm, Instruction, Junction, Junctions, MultiLocation, OriginKind, SendXcm, WeightLimit,
|
||||
Xcm,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -220,9 +221,13 @@ impl<T: Config> Pallet<T> {
|
||||
let new_core_count = notification.new_config.coretime_cores;
|
||||
if new_core_count != old_core_count {
|
||||
let core_count: u16 = new_core_count.saturated_into();
|
||||
let message = Xcm(vec![mk_coretime_call(
|
||||
crate::coretime::CoretimeCalls::NotifyCoreCount(core_count),
|
||||
)]);
|
||||
let message = Xcm(vec![
|
||||
Instruction::UnpaidExecution {
|
||||
weight_limit: WeightLimit::Unlimited,
|
||||
check_origin: None,
|
||||
},
|
||||
mk_coretime_call(crate::coretime::CoretimeCalls::NotifyCoreCount(core_count)),
|
||||
]);
|
||||
if let Err(err) = send_xcm::<T::SendXcm>(
|
||||
MultiLocation {
|
||||
parents: 0,
|
||||
@@ -247,7 +252,7 @@ fn mk_coretime_call(call: crate::coretime::CoretimeCalls) -> Instruction<()> {
|
||||
origin_kind: OriginKind::Superuser,
|
||||
// Largest call is set_lease with 1526 byte:
|
||||
// Longest call is reserve() with 31_000_000
|
||||
require_weight_at_most: Weight::from_parts(100_000_000, 20_000),
|
||||
require_weight_at_most: Weight::from_parts(110_000_000, 20_000),
|
||||
call: BrokerRuntimePallets::Broker(call).encode().into(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,29 +13,30 @@ async function run(nodeName, networkInfo, _jsArgs) {
|
||||
const calls = [
|
||||
// Default broker configuration
|
||||
api.tx.broker.configure({
|
||||
advanceNotice: 2,
|
||||
advanceNotice: 5,
|
||||
interludeLength: 1,
|
||||
leadinLength: 1,
|
||||
regionLength: 3,
|
||||
regionLength: 1,
|
||||
idealBulkProportion: 100,
|
||||
limitCoresOffered: null,
|
||||
renewalBump: 10,
|
||||
contributionTimeout: 5,
|
||||
}),
|
||||
// Make reservation for ParaId 100 (adder-a) every other block
|
||||
// and ParaId 101 (adder-b) every other block.
|
||||
api.tx.broker.reserve([
|
||||
{
|
||||
mask: [255, 0, 255, 0, 255, 0, 255, 0, 255, 0],
|
||||
assignment: { Task: 100 },
|
||||
},
|
||||
{
|
||||
mask: [0, 255, 0, 255, 0, 255, 0, 255, 0, 255],
|
||||
assignment: { Task: 101 },
|
||||
},
|
||||
]),
|
||||
// Start sale with 1 core starting at 1 planck
|
||||
api.tx.broker.startSales(1, 1),
|
||||
// We need MOARE cores.
|
||||
api.tx.broker.requestCoreCount(2),
|
||||
// Set a lease for the broker chain itself.
|
||||
api.tx.broker.setLease(
|
||||
1005,
|
||||
1000,
|
||||
),
|
||||
// Set a lease for parachain 100
|
||||
api.tx.broker.setLease(
|
||||
100,
|
||||
1000,
|
||||
),
|
||||
// Start sale to make the broker "work", but we don't offer any cores
|
||||
// as we have fixed leases only anyway.
|
||||
api.tx.broker.startSales(1, 0),
|
||||
];
|
||||
const sudo_batch = api.tx.sudo.sudo(api.tx.utility.batch(calls));
|
||||
|
||||
|
||||
@@ -1,18 +1,37 @@
|
||||
const assert = require("assert");
|
||||
|
||||
async function run(nodeName, networkInfo, _jsArgs) {
|
||||
const { wsUri, userDefinedTypes } = networkInfo.nodesByName[nodeName];
|
||||
const init = networkInfo.nodesByName[nodeName];
|
||||
let wsUri = init.wsUri;
|
||||
let userDefinedTypes = init.userDefinedTypes;
|
||||
const api = await zombie.connect(wsUri, userDefinedTypes);
|
||||
|
||||
const sec = networkInfo.nodesByName["collator-para-100"];
|
||||
wsUri = sec.wsUri;
|
||||
userDefinedTypes = sec.userDefinedTypes;
|
||||
|
||||
const api_collator = await zombie.connect(wsUri, userDefinedTypes);
|
||||
|
||||
await zombie.util.cryptoWaitReady();
|
||||
|
||||
// Get the genesis header and the validation code of parachain 100
|
||||
const genesis_header = await api_collator.rpc.chain.getHeader();
|
||||
const validation_code = await api_collator.rpc.state.getStorage("0x3A636F6465");
|
||||
|
||||
// account to submit tx
|
||||
const keyring = new zombie.Keyring({ type: "sr25519" });
|
||||
const alice = keyring.addFromUri("//Alice");
|
||||
|
||||
const calls = [
|
||||
api.tx.configuration.setCoretimeCores({ new: 1 }),
|
||||
api.tx.coretime.assignCore(0, 20,[[ { task: 1005 }, 57600 ]], null)
|
||||
api.tx.coretime.assignCore(0, 20,[[ { task: 1005 }, 57600 ]], null),
|
||||
api.tx.registrar.forceRegister(
|
||||
alice.address,
|
||||
0,
|
||||
100,
|
||||
genesis_header.toHex(),
|
||||
validation_code.toHex(),
|
||||
)
|
||||
];
|
||||
const sudo_batch = api.tx.sudo.sudo(api.tx.utility.batch(calls));
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ command = "polkadot"
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "alice"
|
||||
args = ["-lruntime=debug,parachain=trace" ]
|
||||
args = ["-lruntime=debug,xcm=trace" ]
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "bob"
|
||||
@@ -24,35 +24,18 @@ chain = "coretime-rococo-local"
|
||||
|
||||
[parachains.collator]
|
||||
name = "coretime-collator"
|
||||
image = "{{COL_IMAGE}}"
|
||||
image = "{{CUMULUS_IMAGE}}"
|
||||
command = "polkadot-parachain"
|
||||
args = [ "-lruntime=debug,parachain=trace" ]
|
||||
args = [ "-lruntime=debug,xcm=trace" ]
|
||||
|
||||
[[parachains]]
|
||||
id = 100
|
||||
add_to_genesis = false
|
||||
register_para = true
|
||||
register_para = false
|
||||
onboard_as_parachain = false
|
||||
|
||||
[parachains.collator]
|
||||
name = "adder-a"
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "adder-collator"
|
||||
args = [ "-lruntime=debug,parachain=trace" ]
|
||||
|
||||
[[parachains]]
|
||||
id = 101
|
||||
add_to_genesis = false
|
||||
register_para = true
|
||||
onboard_as_parachain = false
|
||||
|
||||
[parachains.collator]
|
||||
name = "adder-b"
|
||||
image = "{{COL_IMAGE}}"
|
||||
command = "adder-collator"
|
||||
args = [ "-lruntime=debug,parachain=trace" ]
|
||||
|
||||
[types.Header]
|
||||
number = "u64"
|
||||
parent_hash = "Hash"
|
||||
post_state = "Hash"
|
||||
name = "collator-para-100"
|
||||
image = "{{CUMULUS_IMAGE}}"
|
||||
command = "polkadot-parachain"
|
||||
args = ["-lruntime=debug,parachain=trace,aura=trace", "--force-authoring"]
|
||||
|
||||
@@ -5,15 +5,11 @@ Creds: config
|
||||
alice: is up
|
||||
coretime-collator: is up
|
||||
|
||||
alice: reports block height is at least 3 within 30 seconds
|
||||
# configure relay chain
|
||||
alice: js-script ./0004-configure-relay.js with "" return is 0 within 600 secs
|
||||
|
||||
# Wait 2 sessions. The parachain doesn't start block production immediately.
|
||||
alice: log line contains "New session detected session_index=2" within 600 seconds
|
||||
|
||||
# configure broker chain
|
||||
coretime-collator: js-script ./0004-configure-broker.js with "" return is 0 within 600 secs
|
||||
|
||||
# TODO: Fix this
|
||||
# alice: parachain 100 block height is at least 10 within 600 seconds
|
||||
# Ensure that parachain 100 got onboarded
|
||||
alice: parachain 100 block height is at least 5 within 900 seconds
|
||||
|
||||
Reference in New Issue
Block a user