Skip to content
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

Merged
merged 3 commits into from
Aug 22, 2023
Merged

PoT gossip refactoring #1838

merged 3 commits into from
Aug 22, 2023

Conversation

nazar-pc
Copy link
Member

This is a small refactoring that essentially removed NodeClient and converted PotGossip into PotGossipWorker 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 use PotProof instead of Vec<u8> as much as possible now.

I did not change initialization or anything like that here, just rearranged things.

Code contributor checklist:

… can be used independently and remove `PotClient` as unnecessary, remove gossip stuff from `TimeKeeper`
Copy link
Contributor

@rahulksnv rahulksnv left a 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) {
Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh ok .. the proposal:

  1. run() would just spawn the std thread and exit
  2. 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

Copy link
Member Author

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) {
Copy link
Contributor

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

Copy link
Member Author

@nazar-pc nazar-pc Aug 22, 2023

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.

@nazar-pc nazar-pc merged commit f782f72 into main Aug 22, 2023
9 checks passed
@nazar-pc nazar-pc deleted the pot-gossip-refactoring branch August 22, 2023 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants