-
Notifications
You must be signed in to change notification settings - Fork 248
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
PoT gossip refactoring #1838
PoT gossip refactoring #1838
Conversation
… can be used independently and remove `PotClient` as unnecessary, remove gossip stuff from `TimeKeeper`
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.
LGTM thanks
} | ||
} | ||
|
||
/// Runs the time keeper processing loop. | ||
pub async fn run(self) { | ||
pub async fn run(mut self) { |
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.
We could potentially get rid of run() completely?, as it only proxies messages to gossip worker after this change
The producer thread can use something like https://docs.rs/tokio/latest/tokio/runtime/struct.Handle.html#method.block_on to directly send message to gossip worker
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.
block_on
is a blocking operation, not sure how you want to use it here. fn run
returns future that is driven by something external. If something external doesn't need it anymore (node is shutting down for instance), then future will be dropped.
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.
The producer thread is a std thread, does this currently:
} else if let Err(error) = proof_sender.blocking_send(next_proof.clone()) {
warn!(%error, "Produce proofs: send failed");
return;
}
I don't understand your concern
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.
blocking_send
is happening from a dedicated thread, run
is an async function. I don't understand what you're proposing here.
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.
Uh ok .. the proposal:
- run() would just spawn the std thread and exit
- The bounded channel would be shared between this std thread and gossip worker. The producer thread would directly send the proofs on this to gossip (several ways to implement this)
Or you can leave it as is, will make a follow up PR
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.
I temporarily abandoned Timekeeper as a data structure in the local WIP branch, didn't see the point in a struct, will have to see what to do about it once I get to connecting it with gossip again.
@@ -95,22 +132,102 @@ impl<Block: BlockT> PotGossip<Block> { | |||
} | |||
} | |||
} | |||
|
|||
/// Initializes the chain state from the consensus tip info. | |||
async fn initialize(&self) { |
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.
I am not sure about initialize() happening both from the time keeper and the gossip components, particularly in the context of the node restart, etc that we talked about (this may be ok, but not clear right now). After 1860, 1861 the init path would be simplified, so it probably is fine then
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.
Next PR actually removed all initialization of gossip, I think I'll have to change it since initialization changes there as well.
This is a small refactoring that essentially removed
NodeClient
and convertedPotGossip
intoPotGossipWorker
that is instantiated directly and unconditionally.TimeKeeper
no longer intantiates gossip engine, it just has a handle to gossip locally produced proofs to the network. There is also a bit more type safety since we usePotProof
instead ofVec<u8>
as much as possible now.I did not change initialization or anything like that here, just rearranged things.
Code contributor checklist: