Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Do not leak active head data in statement distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
koute committed Jul 26, 2021
1 parent 5dac532 commit 8449d2c
Showing 1 changed file with 34 additions and 14 deletions.
48 changes: 34 additions & 14 deletions node/network/statement-distribution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1856,24 +1856,44 @@ impl StatementDistribution {
"New active leaf",
);

let session_index = runtime.get_session_index(ctx.sender(), relay_parent).await?;
let info = runtime.get_session_info_by_index(ctx.sender(), relay_parent, session_index).await?;
let session_info = &info.session_info;

active_heads.entry(relay_parent)
.or_insert(ActiveHeadData::new(session_info.validators.clone(), session_index, span));

active_heads.retain(|h, _| {
let live = !deactivated.contains(h);
if !live {
let session_index = match runtime.get_session_index(ctx.sender(), relay_parent).await {
Ok(session_index) => session_index,
Err(error) => {
tracing::trace!(
target: LOG_TARGET,
hash = ?relay_parent,
"Couldn't activate leaf: no session index found: {}",
error
);
continue;
}
};
let info = match runtime.get_session_info_by_index(ctx.sender(), relay_parent, session_index).await {
Ok(info) => info,
Err(error) => {
tracing::trace!(
target: LOG_TARGET,
hash = ?h,
"Deactivating leaf",
hash = ?relay_parent,
"Couldn't activate leaf: no session info found: {}",
error
);
continue;
}
live
});
};

let session_info = &info.session_info;
active_heads.entry(relay_parent)
.or_insert(ActiveHeadData::new(session_info.validators.clone(), session_index, span));
}

for deactivated in deactivated {
if active_heads.remove(&deactivated).is_some() {
tracing::trace!(
target: LOG_TARGET,
hash = ?deactivated,
"Deactivating leaf",
);
}
}
}
FromOverseer::Signal(OverseerSignal::BlockFinalized(..)) => {
Expand Down

0 comments on commit 8449d2c

Please sign in to comment.