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

task(lib/grandpa): ensure messages are stored and re-processed when needed #2107

Merged
merged 20 commits into from
Jan 11, 2022

Conversation

kishansagathiya
Copy link
Contributor

@kishansagathiya kishansagathiya commented Dec 8, 2021

Changes

  • We are storing grandpa notification messages in cache to make sure that we send them only one. If the message was a consensus messages, we were sending it even if it was already sent.
  • With this PR, we will not be sending consensus messages again, if they were already sent. The receiver keeps track of received messages that they could not process, so that they can be processed in future. (check usage of addVote for more context)

Tests

  • check that tests for dot/network and lib/grandpa passes and so does other relevant tests
  • run grandpa rounds, check that we don't see votes that we already have

Issues

Primary Reviewer

@kishansagathiya kishansagathiya force-pushed the kishan/task/grandpa-messages branch from 3d20301 to e4c791e Compare December 9, 2021 16:32
@kishansagathiya kishansagathiya changed the title ensure messages are stored and re-processed when needed task(lib/grandpa): ensure messages are stored and re-processed when needed Dec 10, 2021
@codecov
Copy link

codecov bot commented Dec 10, 2021

Codecov Report

Merging #2107 (2ae41d4) into development (ccf12de) will increase coverage by 0.00%.
The diff coverage is 63.41%.

Impacted file tree graph

@@             Coverage Diff              @@
##           development    #2107   +/-   ##
============================================
  Coverage        61.56%   61.57%           
============================================
  Files              213      213           
  Lines            27448    27461   +13     
============================================
+ Hits             16898    16908   +10     
- Misses            8683     8684    +1     
- Partials          1867     1869    +2     
Flag Coverage Δ
unit-tests 61.57% <63.41%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
lib/grandpa/message_handler.go 63.50% <30.00%> (-0.93%) ⬇️
dot/network/notifications.go 64.50% <50.00%> (-0.13%) ⬇️
lib/grandpa/message_tracker.go 66.15% <69.23%> (-4.34%) ⬇️
lib/grandpa/grandpa.go 59.05% <100.00%> (+0.21%) ⬆️
lib/grandpa/network.go 47.40% <100.00%> (+0.64%) ⬆️
lib/grandpa/vote_message.go 81.96% <100.00%> (ø)
dot/network/message_cache.go 58.33% <0.00%> (-8.34%) ⬇️
dot/network/light.go 85.25% <0.00%> (-0.80%) ⬇️
lib/runtime/wasmer/imports.go 48.71% <0.00%> (+0.05%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e7c964e...2ae41d4. Read the comment docs.

Copy link
Contributor

@qdm12 qdm12 left a comment

Choose a reason for hiding this comment

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

There are still a few comments / TODOs I'm not sure how to address, let's see what others have to say 😉

dot/network/notifications.go Outdated Show resolved Hide resolved
lib/grandpa/grandpa.go Outdated Show resolved Hide resolved
lib/grandpa/message_tracker.go Show resolved Hide resolved
lib/grandpa/message_tracker.go Outdated Show resolved Hide resolved
dot/network/notifications.go Outdated Show resolved Hide resolved
lib/grandpa/grandpa.go Outdated Show resolved Hide resolved
@@ -93,6 +101,7 @@ func (t *tracker) handleBlock(b *types.Block) {
h := b.Header.Hash()
if vms, has := t.voteMessages[h]; has {
for _, v := range vms {
// handleMessage would never error for vote message
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe update the warn log? :p

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure what you want here? Add this comment in log or remove the log?

lib/grandpa/vote_message.go Outdated Show resolved Hide resolved
Copy link
Contributor

@noot noot left a comment

Choose a reason for hiding this comment

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

looks good, going to try this on the devnet to make sure there's no regressions, then i will approve :p

noot
noot approved these changes Dec 15, 2021
@kishansagathiya kishansagathiya requested review from qdm12 and removed request for arijitAD January 4, 2022 05:57
dot/network/notifications.go Outdated Show resolved Hide resolved
dot/network/notifications.go Outdated Show resolved Hide resolved
dot/network/notifications.go Show resolved Hide resolved
lib/grandpa/grandpa.go Show resolved Hide resolved
lib/grandpa/grandpa.go Outdated Show resolved Hide resolved
lib/grandpa/message_handler.go Outdated Show resolved Hide resolved
lib/grandpa/message_handler.go Show resolved Hide resolved
lib/grandpa/vote_message.go Outdated Show resolved Hide resolved
lib/grandpa/vote_message.go Outdated Show resolved Hide resolved
lib/grandpa/vote_message.go Outdated Show resolved Hide resolved
kishansagathiya and others added 4 commits January 5, 2022 17:47
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
@EclesioMeloJunior
Copy link
Member

@noot @kishansagathiya should we add in the MessageHandler.handleCatchUpResponse a code (if the handle was successful) to check if the given message was stored in the tracker and then remove it?

Copy link
Member

@EclesioMeloJunior EclesioMeloJunior left a comment

Choose a reason for hiding this comment

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

LGTM

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.

4 participants