-
Notifications
You must be signed in to change notification settings - Fork 815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1190: better interface for launch-approval #1355
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -45,7 +45,7 @@ use polkadot_node_subsystem_util::{ | |||
self, | ||||
database::Database, | ||||
metrics::{self, prometheus}, | ||||
runtime::{Config as RuntimeInfoConfig, RuntimeInfo}, | ||||
runtime::{Config as RuntimeInfoConfig, ExtendedSessionInfo, RuntimeInfo}, | ||||
TimeoutExt, | ||||
}; | ||||
use polkadot_primitives::{ | ||||
|
@@ -643,32 +643,46 @@ impl CurrentlyCheckingSet { | |||
} | ||||
} | ||||
|
||||
async fn get_session_info<'a, Sender>( | ||||
async fn get_extended_session_info<'a, Sender>( | ||||
runtime_info: &'a mut RuntimeInfo, | ||||
sender: &mut Sender, | ||||
relay_parent: Hash, | ||||
session_index: SessionIndex, | ||||
) -> Option<&'a SessionInfo> | ||||
) -> Option<&'a ExtendedSessionInfo> | ||||
where | ||||
Sender: SubsystemSender<RuntimeApiMessage>, | ||||
{ | ||||
match runtime_info | ||||
.get_session_info_by_index(sender, relay_parent, session_index) | ||||
.await | ||||
{ | ||||
Ok(extended_info) => Some(&extended_info.session_info), | ||||
Ok(extended_info) => Some(&extended_info), | ||||
Err(_) => { | ||||
gum::debug!( | ||||
target: LOG_TARGET, | ||||
session = session_index, | ||||
?relay_parent, | ||||
"Can't obtain SessionInfo" | ||||
"Can't obtain SessionInfo or ExecutorParams" | ||||
); | ||||
None | ||||
}, | ||||
} | ||||
} | ||||
|
||||
async fn get_session_info<'a, Sender>( | ||||
runtime_info: &'a mut RuntimeInfo, | ||||
sender: &mut Sender, | ||||
relay_parent: Hash, | ||||
session_index: SessionIndex, | ||||
) -> Option<&'a SessionInfo> | ||||
where | ||||
Sender: SubsystemSender<RuntimeApiMessage>, | ||||
{ | ||||
get_extended_session_info(runtime_info, sender, relay_parent, session_index) | ||||
.await | ||||
.map(|extended_info| &extended_info.session_info) | ||||
} | ||||
|
||||
struct State { | ||||
keystore: Arc<LocalKeystore>, | ||||
slot_duration_millis: u64, | ||||
|
@@ -746,6 +760,7 @@ enum Action { | |||
relay_block_hash: Hash, | ||||
candidate_index: CandidateIndex, | ||||
session: SessionIndex, | ||||
executor_params: ExecutorParams, | ||||
candidate: CandidateReceipt, | ||||
backing_group: GroupIndex, | ||||
}, | ||||
|
@@ -968,6 +983,7 @@ async fn handle_actions<Context>( | |||
relay_block_hash, | ||||
candidate_index, | ||||
session, | ||||
executor_params, | ||||
candidate, | ||||
backing_group, | ||||
} => { | ||||
|
@@ -1008,14 +1024,7 @@ async fn handle_actions<Context>( | |||
}, | ||||
None => { | ||||
let ctx = &mut *ctx; | ||||
let executor_params = match session_info_provider | ||||
.get_session_info_by_index(ctx.sender(), block_hash, session) | ||||
.await | ||||
{ | ||||
Err(_) => None, | ||||
Ok(extended_session_info) => | ||||
Some(extended_session_info.executor_params.clone()), | ||||
}; | ||||
|
||||
currently_checking_set | ||||
.insert_relay_block_hash( | ||||
candidate_hash, | ||||
|
@@ -2337,17 +2346,18 @@ async fn process_wakeup<Context>( | |||
_ => return Ok(Vec::new()), | ||||
}; | ||||
|
||||
let session_info = match get_session_info( | ||||
session_info_provider, | ||||
ctx.sender(), | ||||
block_entry.parent_hash(), | ||||
block_entry.session(), | ||||
) | ||||
.await | ||||
{ | ||||
Some(i) => i, | ||||
None => return Ok(Vec::new()), | ||||
}; | ||||
let ExtendedSessionInfo { ref session_info, ref executor_params, .. } = | ||||
match get_extended_session_info( | ||||
session_info_provider, | ||||
ctx.sender(), | ||||
block_entry.parent_hash(), | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the only difference is that we now fetch executor params using parent_hash of relay_block instead of relay_block, but they should be in the same session, right? Otherwise, why would be passing block_entry.session() and not session of parent? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, why do we use parent_hash here? Shouldn't it be relay_block as in other places
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They don't even have to be in the same session. The more current head is technically better, for reasons Rob pointed out but also because even if those two would at some point (with impl changes) end up being in different sessions, the newer one would still have access to the session of the other, while the opposite might not be true. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
yes, this sounds right to me. |
||||
block_entry.session(), | ||||
) | ||||
.await | ||||
{ | ||||
Some(i) => i, | ||||
None => return Ok(Vec::new()), | ||||
}; | ||||
|
||||
let block_tick = slot_number_to_tick(state.slot_duration_millis, block_entry.slot()); | ||||
let no_show_duration = slot_number_to_tick( | ||||
|
@@ -2434,6 +2444,7 @@ async fn process_wakeup<Context>( | |||
relay_block_hash: relay_block, | ||||
candidate_index: i as _, | ||||
session: block_entry.session(), | ||||
executor_params: executor_params.clone(), | ||||
candidate: candidate_receipt, | ||||
backing_group, | ||||
}); | ||||
|
@@ -2475,7 +2486,7 @@ async fn launch_approval<Context>( | |||
validator_index: ValidatorIndex, | ||||
block_hash: Hash, | ||||
backing_group: GroupIndex, | ||||
executor_params: Option<ExecutorParams>, | ||||
executor_params: ExecutorParams, | ||||
span: &jaeger::Span, | ||||
) -> SubsystemResult<RemoteHandle<ApprovalState>> { | ||||
let (a_tx, a_rx) = oneshot::channel(); | ||||
|
@@ -2546,11 +2557,6 @@ async fn launch_approval<Context>( | |||
// Force the move of the timer into the background task. | ||||
let _timer = timer; | ||||
|
||||
let executor_params = match executor_params { | ||||
Some(ep) => ep, | ||||
None => return ApprovalState::failed(validator_index, candidate_hash), | ||||
}; | ||||
|
||||
let available_data = match a_rx.await { | ||||
Err(_) => return ApprovalState::failed(validator_index, candidate_hash), | ||||
Ok(Ok(a)) => a, | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really not how the usage was intended, but that was the case before already.