-
Notifications
You must be signed in to change notification settings - Fork 379
Parachain Warp Sync #1619
Comments
@skunert Have you started work on this? I would love the chance to contribute if possible 😄 |
I have not yet started working on this, feel free to give it a try of you want! |
Awesome, thanks @skunert. I am on element if you want to have a chat about it. |
@bkchr @skunert can you give me some guidance on where to start with this? looking at how the relay chain does warp I am not sure we can replicate the same But from Basti's comments I am not sure we are meant to replicate it anyways. So what does an ideal implementation for this ticket look like? A new component similar to how it's done on substrate? Is there any other implementation you would want me to look at to keep things consistent? |
The best is that you make yourself familiar with the grandpa warp sync implementation in Substrate. The idea in the end will probably be around making the warp sync implementation generic. Yeah, the best is really to read the code and try to come up with a proposal. We don't have any concrete implementation in our minds. |
Hey folks I have been looking at the grandpa implementation of warp sync on substrate and on Polkadot and I have a few questions When Basti says "extract the Parachain header." How do I do that? Is there an example I can reference of how we use it with How will it differ compared to the current fast sync? |
cumulus/client/consensus/common/src/parachain_consensus.rs Lines 425 to 433 in 981b5d0
No.
Parachain Warp Sync will not be really "warp sync". Aka it doesn't follow the validator set changes etc, because we don't need to do this for parachains. Parachains get their consensus from the relay chain. So, we need the relay chain to warp sync to the latest finalized block and then get the parachain header from the relay chain block. This parachain header is then feed into |
Thank you so much Basti this is great help and gives me a better idea where to start Iim really keen on contributing and building, because I feel like that's how I can give the most value to the ecosystem rather than just helping you design it. Plus it gets me even more familiar with substrate and grandpa which is a good thing in my book I'll try to get a test around it because I think that's the best way for me to understand the flow |
Hey guys I have been looking at this in depth over the past week and I have a few questions I decided to split the work into 2 sections
The plan is to get 1 done first Looking into grandpa, The sync works by defining a Network Provider While the default implementation for this is a Warp Sync Provider The Based on my understanding and from the helpful comments above, we don't need all of this because we - in Cumulus template node - will already know when the relay chain is synced from the
So here is what I was thinking of implementing we could create a My question is should we be implementing it via Or have I gone down the wrong rabbit hole and we should instead be building our own |
No we don't want this.
We don't need to generate or verify any warp proofs as we already know what the best block is. You need to change the sync code to support this kind of "special" sync mode here. A sync mode that gets a header set and then starts state sync for this header. |
I get that but cumulus does not contain any sync code, so do you mean to change the substrate sync client? I would think we would need to change the Or perhaps there is a way of doing this only on Cumulus without changing the underlying substrate code, but given this trait is whats then used when building the network....... Also, since we don't need to generate or verify proofs, my gut is telling me that we shouldn't even be implementing the current |
Yes, but we should probably call it different. Maybe the easiest way is just to have some other kind of "sync implementation". Alongside warp/fast/state. |
Agreed, Ill just go with We can either create a base trait called Or change In your opinion, which is the "cleaner" approach? |
I don't get what you mean here. |
I mean in general we could probably write some sort of abstract |
I mean have a base trait called
Then the changes we need to implement will be in https://github.com/paritytech/substrate/blob/master/client/service/src/builder.rs#L762-L770 Where the parameter we pass in will be a |
As far as I understand it will be basically |
What do you mean by this? Which constructor? I originally thought it should be part of Should we just be passing in an optional parameter to |
|
@samelamin here: https://github.com/paritytech/substrate/blob/59a74b18df148b9b4b460ba1d0322948f96d04d0/client/service/src/builder.rs#L733-L734 You could change this to some kind of enum:
This params enum would then be passed to the The internals of |
Got it Basti thanks This is what I am intending to do
Does the above seem like a good approach? |
You don't need this. As I explained above, you would pass the channel for sending the header on initialization. |
I just wanted to give heads up that I have one big PR coming hopefully by the end of this week that will move the syncing out of |
Looks good to me. I'd prefer an explicit method rather than a channel, but that's not a strong opinion. Channel is also OK |
We can also put a function into the sync handle. However, as @altonen already hinted, putting this function into NetworkService is wrong. |
Quick question on this that occurred to me while editing WarpSync Since we are passing this enum, doesn't that mean that we will have to make WarpSyncProvider and the phase optional , because for the new sync type both for example
Or should we be removing the |
@samelamin these are now really implementation details. Please bring up a pr with a good code design. For sure you will need to make the provider optional, but how, there are multiple ways. |
The simplest solution is to simply move it to the Phase can't be |
Hello folks I submitted prs for the first part of this Issue which is passing I will now work on the cumulus part to wait on the relay chain to finish syncing and pass the header to the onshot receiver on |
This issue has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/polkadot-release-analysis-v0-9-39/2277/1 |
Finished! :) |
Currently we don't support warp sync in parachains. We will need to write some Warp sync implementation for Parachains. The idea is that we first warp sync the relay chain and then get the latest header of the Parachain. After we got this header we can use
StateSync
on the Parachain side to get the state.Depending on how the relay chain node is integrated, we can do the relay chain warp sync differently:
The text was updated successfully, but these errors were encountered: