Skip to content

Commit

Permalink
fix track core assignments after runtime v1000000
Browse files Browse the repository at this point in the history
  • Loading branch information
paulormart committed Nov 10, 2023
1 parent 1879591 commit 0b97c0f
Showing 1 changed file with 36 additions and 20 deletions.
56 changes: 36 additions & 20 deletions src/runtimes/kusama.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1269,32 +1269,48 @@ pub async fn track_records(
}

// ***********************************************************************
// Track Core Assignments
// Track Core Assignments only after specVersion > 1000000
// ***********************************************************************
// Fetch availability_cores
let availability_cores_addr = node_runtime::storage()
.para_scheduler()
.availability_cores();
// Fetch last_runtime_upgrade
let last_runtime_upgrade_addr =
node_runtime::storage().system().last_runtime_upgrade();

if let Some(availability_cores) = api
if let Some(info) = api
.storage()
.at(block_hash)
.fetch(&availability_cores_addr)
.fetch(&last_runtime_upgrade_addr)
.await?
{
for (i, core_occupied) in availability_cores.iter().enumerate() {
let core_idx = u32::try_from(i).unwrap();
match &core_occupied {
CoreOccupied::Free => records
.update_core_free(core_idx, Some(backing_votes.session)),
CoreOccupied::Paras(paras_entry) => {
// destructure para_id
let Id(para_id) = paras_entry.assignment.para_id;
records.update_core_by_para_id(
para_id,
core_idx,
Some(backing_votes.session),
);
if info.spec_version >= 1000000 {
// Fetch availability_cores
let availability_cores_addr = node_runtime::storage()
.para_scheduler()
.availability_cores();

if let Some(availability_cores) = api
.storage()
.at(block_hash)
.fetch(&availability_cores_addr)
.await?
{
for (i, core_occupied) in availability_cores.iter().enumerate()
{
let core_idx = u32::try_from(i).unwrap();
match &core_occupied {
CoreOccupied::Free => records.update_core_free(
core_idx,
Some(backing_votes.session),
),
CoreOccupied::Paras(paras_entry) => {
// destructure para_id
let Id(para_id) = paras_entry.assignment.para_id;
records.update_core_by_para_id(
para_id,
core_idx,
Some(backing_votes.session),
);
}
}
}
}
}
Expand Down

0 comments on commit 0b97c0f

Please sign in to comment.