Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Grandpa warp sync request-response protocol #7711

Merged
42 commits merged into from
Jan 21, 2021
Merged

Conversation

expenses
Copy link
Contributor

See #1208. A messy first draft of a full-node request-response protocol for use with paritytech/smoldot#294. Essentially this takes @cheme's branch master...cheme:light_grandpa_warp and adds a request-response protocol on top.

@github-actions github-actions bot added the A3-in_progress Pull request is in progress. No review needed at this stage. label Dec 10, 2020
@tomaka
Copy link
Contributor

tomaka commented Jan 4, 2021

Is this PR unfinished?
I'd have a few review comments, but is there a reason to not mark it as ready start the review process?

@expenses
Copy link
Contributor Author

expenses commented Jan 4, 2021

This PR is basically the minimum amount of changes I needed to make to @cheme 's branch in order to get grandpa warp sync to work in substrate-lite. There are definately some things that need to be changed before it can be merged, getting the inspect subcommand working again is a big one. I'll change it to allow reviews anyway though.

@expenses expenses marked this pull request as ready for review January 4, 2021 10:20
@expenses expenses requested a review from andresilva as a code owner January 4, 2021 10:20
@expenses expenses requested a review from cheme January 5, 2021 13:36
pub fn new(protocol_id: ProtocolId, backend: Arc<TBackend>) -> (Self, ProtocolConfig) {
// Rate of arrival multiplied with the waiting time in the queue equals the queue length.
//
// An average Polkadot sentry node serves less than 5 requests per second. The 95th percentile
Copy link
Contributor

Choose a reason for hiding this comment

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

Well, that comment isn't true for warp syncing.

Copy link
Contributor

@cheme cheme left a comment

Choose a reason for hiding this comment

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

I see a few TODO from my branch, will try to remove them locally and also check if 'BlockJustification' trait is of any use (can be a remnant of something else that I did not clean).

Copy link
Contributor

@tomaka tomaka left a comment

Choose a reason for hiding this comment

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

Networking stuff looks good to me, but I can't review the rest

@cheme
Copy link
Contributor

cheme commented Jan 12, 2021

I did change a bit the iteration to not include change of authority set when another change is defined during the delay, should handle this case.

I also added a simple cache (last two commit), it can be remove to another pr if needed.

@tomaka
Copy link
Contributor

tomaka commented Jan 14, 2021

Could you please merge master so that the CI fixes itself

Copy link
Contributor

@andresilva andresilva left a comment

Choose a reason for hiding this comment

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

After #7339 we should be able to rewrite the finality proof changes much more clearly. The main change being that we will have a mapping of set_id -> last_block_in_set, which means that we can just fetch justifications from disk based on that rather than iterating through all headers to find them. I have reviewed the changes in finality_proof lightly since based on this I expect this code to be rewritten soon.

I don't want to block this PR any further on it (I can make those changes after #7339 is merged). My only gripe right now is that the warp sync code should exist inside the grandpa crate.

@@ -0,0 +1,28 @@
[package]
description = "A request-response protocol for handling grandpa warp sync requests"
name = "sc-grandpa-warp-sync"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why create a new crate for this? I think it should just go in the existing grandpa crate. This also avoids having to expose some grandpa internals.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's better to have it as a standalone crate IMO as it only can be used when BABE is also being used afaik.

Copy link
Contributor

Choose a reason for hiding this comment

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

As it exists now I think it's independent from the block production protocol, it's creating finality proofs from genesis to some latest finalized block regardless of how that block itself is validated (although it's true that we also need to fetch BABE data elsewhere). I won't press on moving this to the grandpa crate but can we rename it to sc-finality-grandpa-warp-sync so the naming is closer to the other crate?

@andresilva
Copy link
Contributor

@andresilva , just to confirm, in this case the change at #10 is ignored in favor of the fork at #11?

I had not reviewed the PR yet when I answered this question. For our purposes, as long as we find a justification then we can be sure it is the correct one. Otherwise this would mean that GRANDPA finalized contradicting things (i.e. different forks). The existing code lgtm.

@tomaka
Copy link
Contributor

tomaka commented Jan 15, 2021

Merging master should hopefully now fix CI.

@tomaka
Copy link
Contributor

tomaka commented Jan 21, 2021

If this PR satisfies everyone, I'd like to merge it today or tomorrow so that it is included in the upcoming Polkadot 0.7.28.
If someone has any last minute objection, they shall speak now or forever hold their peace.

@andresilva
Copy link
Contributor

Approving so we won't block this any further (as it blocks work on smoldot). But the finality_proof.rs changes will be refactored/rewritten after #7339 is in (I can create a PR for it afterwards).

@tomaka
Copy link
Contributor

tomaka commented Jan 21, 2021

(I DM'ed @cheme and no objection either)

@tomaka
Copy link
Contributor

tomaka commented Jan 21, 2021

bot merge

@ghost
Copy link

ghost commented Jan 21, 2021

Trying merge.

@ghost ghost merged commit 4b687df into master Jan 21, 2021
@ghost ghost deleted the ashley-grandpa-warp-sync branch January 21, 2021 17:14
@tomaka tomaka added B5-clientnoteworthy and removed B0-silent Changes should not be mentioned in any release notes labels Jan 21, 2021
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. A3-in_progress Pull request is in progress. No review needed at this stage. C1-low PR touches the given topic and has a low impact on builders.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants