Coretime Feature branch (relay chain) (#1694)

Also fixes: https://github.com/paritytech/polkadot-sdk/issues/1417

- [x] CoreIndex -> AssignmentProvider mapping will be able to change any
time.
- [x] Implement
- [x] Provide Migrations
- [x] Add and fix tests
- [x] Implement bulk assigner logic
- [x] bulk assigner tests
- [x] Port over current assigner to use bulk designer (+ share on-demand
with bulk): top-level assigner has core ranges: legacy, bulk
- [x] Adjust migrations to reflect new assigner structure
- [x] Move migration code to Assignment code directly and make it
recursive (make it possible to skip releases) -> follow up ticket.
- [x] Test migrations
- [x] Add migration PR to runtimes repo -> follow up ticket.
- [x] Wire up with actual UMP messages
- [x] Write PR docs

---------

Co-authored-by: eskimor <eskimor@no-such-url.com>
Co-authored-by: Bradley Olson <34992650+BradleyOlson64@users.noreply.github.com>
Co-authored-by: BradleyOlson64 <lotrftw9@gmail.com>
Co-authored-by: Anton Vilhelm Ásgeirsson <antonva@users.noreply.github.com>
Co-authored-by: antonva <anton.asgeirsson@parity.io>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Marcin S. <marcin@realemail.net>
Co-authored-by: Bastian Köcher <info@kchr.de>
Co-authored-by: command-bot <>
This commit is contained in:
eskimor
2023-12-21 19:06:58 +01:00
committed by GitHub
parent 18d53dbf91
commit 69434d9a32
71 changed files with 4059 additions and 1213 deletions
@@ -0,0 +1,66 @@
const assert = require("assert");
async function run(nodeName, networkInfo, _jsArgs) {
const { wsUri, userDefinedTypes } = networkInfo.nodesByName[nodeName];
const api = await zombie.connect(wsUri, userDefinedTypes);
await zombie.util.cryptoWaitReady();
// account to submit tx
const keyring = new zombie.Keyring({ type: "sr25519" });
const alice = keyring.addFromUri("//Alice");
const calls = [
// Default broker configuration
api.tx.broker.configure({
advanceNotice: 2,
interludeLength: 1,
leadinLength: 1,
regionLength: 3,
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),
];
const sudo_batch = api.tx.sudo.sudo(api.tx.utility.batch(calls));
await new Promise(async (resolve, reject) => {
const unsub = await sudo_batch.signAndSend(alice, (result) => {
console.log(`Current status is ${result.status}`);
if (result.status.isInBlock) {
console.log(
`Transaction included at blockHash ${result.status.asInBlock}`
);
} else if (result.status.isFinalized) {
console.log(
`Transaction finalized at blockHash ${result.status.asFinalized}`
);
unsub();
return resolve();
} else if (result.isError) {
console.log(`Transaction Error`);
unsub();
return reject();
}
});
});
return 0;
}
module.exports = { run };
@@ -0,0 +1,43 @@
const assert = require("assert");
async function run(nodeName, networkInfo, _jsArgs) {
const { wsUri, userDefinedTypes } = networkInfo.nodesByName[nodeName];
const api = await zombie.connect(wsUri, userDefinedTypes);
await zombie.util.cryptoWaitReady();
// 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)
];
const sudo_batch = api.tx.sudo.sudo(api.tx.utility.batch(calls));
await new Promise(async (resolve, reject) => {
const unsub = await sudo_batch.signAndSend(alice, (result) => {
console.log(`Current status is ${result.status}`);
if (result.status.isInBlock) {
console.log(
`Transaction included at blockHash ${result.status.asInBlock}`
);
} else if (result.status.isFinalized) {
console.log(
`Transaction finalized at blockHash ${result.status.asFinalized}`
);
unsub();
return resolve();
} else if (result.isError) {
console.log(`Transaction Error`);
unsub();
return reject();
}
});
});
return 0;
}
module.exports = { run };
@@ -0,0 +1,58 @@
[settings]
timeout = 1000
[relaychain]
default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}"
chain = "rococo-local"
command = "polkadot"
[[relaychain.nodes]]
name = "alice"
args = ["-lruntime=debug,parachain=trace" ]
[[relaychain.nodes]]
name = "bob"
args = ["-lruntime=debug,parachain=trace" ]
[[relaychain.nodes]]
name = "charlie"
args = ["-lruntime=debug,parachain=trace" ]
[[parachains]]
id = 1005
chain = "coretime-rococo-local"
[parachains.collator]
name = "coretime-collator"
image = "{{COL_IMAGE}}"
command = "polkadot-parachain"
args = [ "-lruntime=debug,parachain=trace" ]
[[parachains]]
id = 100
add_to_genesis = false
register_para = true
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"
@@ -0,0 +1,19 @@
Description: Bulk core assignment Smoke
Network: ./0004-coretime-smoke-test.toml
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