-
Notifications
You must be signed in to change notification settings - Fork 1.6k
refactor overseer into proc-macro based pattern #2962
Conversation
75935ad
to
a38f2b8
Compare
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
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.
Made a few small suggestions. Overall, I think this is fine to merge as-is though
head: Hash, | ||
finalized_number: &Option<BlockNumber>, | ||
) -> SubsystemResult<Vec<BlockImportedCandidates>> { | ||
) -> SubsystemResult<Vec<BlockImportedCandidates>> | ||
{ |
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.
nit: I believe it's standard to have the braces on the same line as the return unless the return is deconstructed (multi-line).
|
||
loop { | ||
futures::select! { | ||
m = receiver.next() => match m.unwrap() { |
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.
nit: single character variables are a bit mysterious. I would suggest msg =
instead of m
and res =
instead of r
{ | ||
fn start(self, ctx: C) -> SpawnedSubsystem { | ||
fn start(self, ctx: Context) -> SpawnedSubsystem { |
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.
Nice!
number_leaves: 0, | ||
finalized_state: None, | ||
} | ||
} |
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.
nit: Spaces between functions?
@@ -148,13 +179,14 @@ macro_rules! specialize_requests { | |||
#[doc = "Request `"] | |||
#[doc = $doc_name] | |||
#[doc = "` from the runtime"] | |||
pub async fn $func_name( | |||
pub async fn $func_name ( |
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.
nit: extra space
I'll take care of the nits in a follow up |
The branch name is historical, this expanded into a refactoring of the
Overseer
into a pattern to actually allow simpler spawning of modified nodes with subsystems that exhibit modified (malicious and/or broken) behavior besides future compile time checks based on subsystem.This is stage one and lies the groundwork for further checks:
AllMessages
and.into()
in any subsystem, always send the subsystem specific types directlyNext steps are covered in #3427
Notes to reviewers:
You will find two traits called
SubsystemContext
, where one binds 3 associated types, the other is a wrapper around it. This was meant to simplifify the trait bounds across all subsystem's generic typeContext
. In retrospective I am not sure which is better:Subsystem<Message=X> + overseer::Subsystem<Message=X>
vsoverseer::Subsystem<Message=X, AllMessages=AllMessages, Signal=OverseerSignal, Error=SubsystemError>
.Most usages of conversions into
AllMessages
aroundfn send_message(..)
were removed, instead almost all instances now do the conversion implicitly which removes quite a bit of clutter and will be necessary for [node] Add additional sanitization checks to overseer #3427 anyways.I moved the
#[cfg(test)] mod tests;
back at the end of the file. It caused a whole lot of duplicate definitions and it's just clearer to have one spot to look for the test module, and that's at the bottom of a file. External or not is imho secondary to that.Most changes are boring trait bounds, so I'd recommend on focusing on the node/overseer/src/lib.rs and more generally on
node/{overseer,subsystem}/*
where the most relevant changes are.