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

grandpa: round catchup messages#2801

Merged
andresilva merged 35 commits intomasterfrom
andre/grandpa-catchup-messages
Jul 4, 2019
Merged

grandpa: round catchup messages#2801
andresilva merged 35 commits intomasterfrom
andre/grandpa-catchup-messages

Conversation

@andresilva
Copy link
Copy Markdown
Contributor

@andresilva andresilva commented Jun 5, 2019

Currently after syncing to the latest authority set, GRANDPA voters will observe new commit messages and start a prospective round based on that (e.g. they're at round 1, they observe a commit for round 10, so they start a prospective round 11). This PR replaces this logic by creating an explicit request mechanism for catching up to the latest round. When we see a neighbor packet from a peer that's at a round N higher than local_round + 2 we issue a catch up request targeted to that node. The receiving node replies back with a catch up message that includes all round data needed (base, prevotes, precommits) to safely jump to that round. Currently the node may reply with a valid catch up message that finalizes any round higher than requested.

Depends on paritytech/finality-grandpa#53.

TODO:

  • Tweak cost / benefit values
  • Tests
  • Docs

@andresilva andresilva added A3-in_progress Pull request is in progress. No review needed at this stage. M4-core labels Jun 5, 2019
set_id: request.set_id,
message: catch_up,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we should update the view of the peer after sending the catch up message. In case of receiving the same catch-up request, do we respond again?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point! I think we should add a validation here that the peer doesn't request a catch up for a round earlier than whatever his view is. If we update their view when we reply to a catch-up then this would prevent DoS but I'm not sure we should do it. I was thinking of adding a cache of last requests in a follow-up PR, and this cache would be used to prevent DoS.

Copy link
Copy Markdown
Contributor

@rphmeier rphmeier Jun 28, 2019

Choose a reason for hiding this comment

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

Updating the view here could be a bit weird, since they might have a neighbor packet in transit that is from before the view we expect them to have upon receiving the catch-up message.

I'd rather simply rate-limit the amount of catch-up messages a peer can send us. ideally we could inform peers of the rate-limiting as well...maybe with a CatchUp::NotUntil(duration_millis) variant. Regular CatchUp responses could also hold that kind of timeout parameter.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Well, that's probably not the right approach considering the PSM...what we should be doing is actually charging the peer a cost for every catch-up request. The hope being that if they spam us, they get disconnected fairly quickly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a static cost to answering a catch up request which is inverse of the benefit the other party gets.

Co-Authored-By: Robert Habermeier <rphmeier@gmail.com>
@andresilva andresilva force-pushed the andre/grandpa-catchup-messages branch from 61b8650 to 4bf6dab Compare July 1, 2019 10:42
@andresilva andresilva added A0-please_review Pull request needs code review. and removed A5-grumble labels Jul 1, 2019
@andresilva
Copy link
Copy Markdown
Contributor Author

I think I've addressed all grumbles. Need to release finality-grandpa 0.8.1 but this should be ready for review.

@rphmeier rphmeier added A6-mustntgrumble and removed A0-please_review Pull request needs code review. labels Jul 1, 2019
@rphmeier
Copy link
Copy Markdown
Contributor

rphmeier commented Jul 1, 2019

I'd like docs on the historical votes to ensure that the property of being a minimal set is maintained. And then the finality-grandpa update as well.

@gavofyork
Copy link
Copy Markdown
Member

on ice until the new finality-grandpa is released.

@gavofyork
Copy link
Copy Markdown
Member

@andresilva please merge once finality-grandpa is updated.

@andresilva
Copy link
Copy Markdown
Contributor Author

finality-grandpa v0.8 released, merging.

@andresilva andresilva merged commit 968ff41 into master Jul 4, 2019
cmichi pushed a commit that referenced this pull request Jul 9, 2019
* grandpa: initial structure for catch up messages

* grandpa: answer catch up requests

* grandpa: inject catch up messages into global stream

* grandpa: keep track of pending catch up request

* grandpa: block catchup until all referenced blocks are imported

* grandpa: unify catch up and commit streams

* grandpa: simplify communication stream/sink types

* grandpa: note gossip validator on catch up message import

* grandpa: fix cost on catch up message validation

* grandpa: check signatures on catch up messages

* grandpa: clean up catch up request handling state

* grandpa: adjust costs on invalid catch up requests

* grandpa: release lock before pushing catch up message

* grandpa: validate catch up request against peer view

* grandpa: catch up docs

* grandpa: fix tests

* grandpa: until_imported: add tests for catch up messages

* grandpa: add tests for catch up message gossip validation

* grandpa: integrate HistoricalVotes changes

* grandpa: add test for neighbor packet triggering catch up

* grandpa: add test for full voter catch up

* grandpa: depend on finality-grandpa 0.8 from crates

* granda: use finality-grandpa test helpers

* grandpa: add PSM cost for answering catch up requests

* grandpa: code style fixes

Co-Authored-By: Robert Habermeier <rphmeier@gmail.com>

* grandpa: more trailing commas

* grandpa: lower cost of invalid catch up requests near set change

* grandpa: process catch up sending on import of neighbor message

* grandpa: add comments on HistoricalVotes

* grandpa: use finality-grandpa v0.8.1 from crates.io

* grandpa: fix test compilation
cmichi pushed a commit that referenced this pull request Jul 9, 2019
* grandpa: initial structure for catch up messages

* grandpa: answer catch up requests

* grandpa: inject catch up messages into global stream

* grandpa: keep track of pending catch up request

* grandpa: block catchup until all referenced blocks are imported

* grandpa: unify catch up and commit streams

* grandpa: simplify communication stream/sink types

* grandpa: note gossip validator on catch up message import

* grandpa: fix cost on catch up message validation

* grandpa: check signatures on catch up messages

* grandpa: clean up catch up request handling state

* grandpa: adjust costs on invalid catch up requests

* grandpa: release lock before pushing catch up message

* grandpa: validate catch up request against peer view

* grandpa: catch up docs

* grandpa: fix tests

* grandpa: until_imported: add tests for catch up messages

* grandpa: add tests for catch up message gossip validation

* grandpa: integrate HistoricalVotes changes

* grandpa: add test for neighbor packet triggering catch up

* grandpa: add test for full voter catch up

* grandpa: depend on finality-grandpa 0.8 from crates

* granda: use finality-grandpa test helpers

* grandpa: add PSM cost for answering catch up requests

* grandpa: code style fixes

Co-Authored-By: Robert Habermeier <rphmeier@gmail.com>

* grandpa: more trailing commas

* grandpa: lower cost of invalid catch up requests near set change

* grandpa: process catch up sending on import of neighbor message

* grandpa: add comments on HistoricalVotes

* grandpa: use finality-grandpa v0.8.1 from crates.io

* grandpa: fix test compilation
MTDK1 pushed a commit to bdevux/substrate that referenced this pull request Jul 10, 2019
* grandpa: initial structure for catch up messages

* grandpa: answer catch up requests

* grandpa: inject catch up messages into global stream

* grandpa: keep track of pending catch up request

* grandpa: block catchup until all referenced blocks are imported

* grandpa: unify catch up and commit streams

* grandpa: simplify communication stream/sink types

* grandpa: note gossip validator on catch up message import

* grandpa: fix cost on catch up message validation

* grandpa: check signatures on catch up messages

* grandpa: clean up catch up request handling state

* grandpa: adjust costs on invalid catch up requests

* grandpa: release lock before pushing catch up message

* grandpa: validate catch up request against peer view

* grandpa: catch up docs

* grandpa: fix tests

* grandpa: until_imported: add tests for catch up messages

* grandpa: add tests for catch up message gossip validation

* grandpa: integrate HistoricalVotes changes

* grandpa: add test for neighbor packet triggering catch up

* grandpa: add test for full voter catch up

* grandpa: depend on finality-grandpa 0.8 from crates

* granda: use finality-grandpa test helpers

* grandpa: add PSM cost for answering catch up requests

* grandpa: code style fixes

Co-Authored-By: Robert Habermeier <rphmeier@gmail.com>

* grandpa: more trailing commas

* grandpa: lower cost of invalid catch up requests near set change

* grandpa: process catch up sending on import of neighbor message

* grandpa: add comments on HistoricalVotes

* grandpa: use finality-grandpa v0.8.1 from crates.io

* grandpa: fix test compilation
@andresilva andresilva deleted the andre/grandpa-catchup-messages branch May 1, 2020 14:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants